/** * @return \AMQPConnection * * Lazy connect */ public function getExchange() { if (!$this->exchange) { if (!$this->connection->isConnected()) { $this->connection->connect(); } $this->exchange = new Exchange(new \AMQPChannel($this->connection)); } return $this->exchange; }
public function __construct(array $amqpConfig, $queueName) { if (!extension_loaded('amqp')) { throw new \RunTimeException("PHP extension 'amqp' is required"); } $con = new Connection($amqpConfig); if (!$con->isConnected()) { $con->connect(); } $this->queue = new Queue(new \AMQPChannel($con), $queueName); }