Example #1
0
 /**
  * SocketConnection constructor.
  * @param ConnectionOptions|array|Traversable $options
  */
 public function __construct($options)
 {
     if (!$options instanceof ConnectionOptions) {
         $options = new ConnectionOptions($options);
     }
     $this->options = $options;
     $this->connection = new BaseAMQPSocketConnection($options->getHost(), $options->getPort(), $options->getLogin(), $options->getPassword(), $options->getVhost(), false, 'AMQPLAIN', null, 'en_US', $options->getReadTimeout() ?: $options->getWriteTimeout(), $options->getHeartbeat() > 0);
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function reconnect() : bool
 {
     if ($this->options->getPersistent()) {
         return $this->connection->preconnect();
     } else {
         return $this->connection->reconnect();
     }
 }
Example #3
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()]);
 }