Пример #1
0
 /**
  * StreamConnection constructor.
  * @param ConnectionOptions|array|Traversable $options
  */
 public function __construct($options)
 {
     if (!$options instanceof ConnectionOptions) {
         $options = new ConnectionOptions($options);
     }
     $this->options = $options;
     $this->connection = new BaseAMQPStreamConnection($options->getHost(), $options->getPort(), $options->getLogin(), $options->getPassword(), $options->getVhost(), false, 'AMQPLAIN', null, 'en_US', $options->getConnectTimeout(), $options->getReadTimeout() ?: $options->getWriteTimeout(), null, $options->getHeartbeat() > 0, $options->getHeartbeat());
 }
Пример #2
0
 /**
  * SslConnection constructor.
  * @param ConnectionOptions|array|Traversable $options
  */
 public function __construct($options)
 {
     if (!$options instanceof ConnectionOptions) {
         $options = new ConnectionOptions($options);
     }
     if (!$options->getCACert()) {
         throw new Exception\InvalidArgumentException('Ca cert file missing in connection options');
     }
     if (!$options->getCert()) {
         throw new Exception\InvalidArgumentException('Cert file missing in connection options');
     }
     if (null === $options->getVerify()) {
         throw new Exception\InvalidArgumentException('SSL verification option is missing connection options');
     }
     $sslOptions = ['cafile' => $options->getCACert(), 'local_cert' => $options->getCert(), 'verify_peer' => $options->getVerify(), 'verify_peer_name' => $options->getVerify()];
     if ($key = $options->getKey()) {
         $sslOptions['local_pk'] = $key;
     }
     $this->options = $options;
     $this->connection = new BaseAMQPSSLConnection($options->getHost(), $options->getPort(), $options->getLogin(), $options->getPassword(), $options->getVhost(), $sslOptions, ['connection_timeout' => $options->getReadTimeout(), 'read_write_timeout' => $options->getWriteTimeout(), 'heartbeat' => $options->getHeartbeat()]);
 }