protected function setUpAmqp() { $this->conn = new AMQPSocketConnection($_SERVER['AMQP_HOST'], $_SERVER['AMQP_PORT'], $_SERVER['AMQP_USER'], $_SERVER['AMQP_PASS'], $_SERVER['AMQP_VHOST']); $this->channel = $this->conn->channel(); $this->channel->exchange_declare('event_band.test.exchange', 'topic'); $this->channel->queue_declare('event_band.test.event'); $this->channel->queue_bind('event_band.test.event', 'event_band.test.exchange', 'event.#'); }
/** * {@inheritdoc} */ protected function setUp() { if (!isset($_SERVER['AMQP_HOST'])) { $this->markTestSkipped('This test require AMQP Server, use AMQP_HOST, AMQP_PORT, AMQP_USER, AMQP_PASSWORD, AMQP_VHOST environment variables to set connection details'); } $this->exchange = uniqid('phpunit.'); $env = function ($key, $default = null) { return isset($_SERVER[$key]) ? $_SERVER[$key] : $default; }; $this->connection = new AMQPStreamConnection($env('AMQP_HOST', 'localhost'), $env('AMQP_PORT', 5672), $env('AMQP_USER', 'guest'), $env('AMQP_PASSWORD', 'guest'), $env('AMQP_VHOST', '/')); $this->channel = $this->connection->channel(); $this->channel->exchange_declare($this->exchange, 'fanout'); $this->client = new ServiceBus(new Driver($this->channel, $this->exchange, new JsonEncoder())); $this->initialize(); }
/** * Setup the exchanges, and queues and channel */ protected function setupChannel() { $this->ch = $this->conn->channel(); $this->ch->exchange_declare($this->exchange, 'direct', false, false, false); $this->ch->queue_declare($this->queue); $this->ch->queue_bind($this->queue, $this->exchange, $this->queue); }
/** * Create a channel from the connection if one does not already exist. * Requires the connection to already have been created. * @return self */ protected function createChannel() { if ($this->channel === null) { $this->channel = $this->connection->channel(); } return $this; }
/** * BaseAmqp constructor. * @param AbstractConnection $connection */ public function __construct(AbstractConnection $connection) { $this->connection = $connection; $this->channel = $this->connection->channel(); }