本文整理汇总了PHP中PhpAmqpLib\Channel\AMQPChannel类的典型用法代码示例。如果您正苦于以下问题:PHP AMQPChannel类的具体用法?PHP AMQPChannel怎么用?PHP AMQPChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AMQPChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getChannel
/**
* Gets publisher AMQ channel
*
* @return AMQPChannel
*/
protected function getChannel()
{
if (null === $this->channel) {
$this->channel = $this->amq->channel();
$this->channel->exchange_declare($this->exchange, 'topic', false, true, false);
}
return $this->channel;
}
示例2:
function it_releases_job_onto_rabbitmq(AMQPChannel $channel, RabbitMQQueue $queue)
{
// delete
$channel->basic_ack('fooTagId')->shouldBeCalled();
// release with attempts added into body
$queue->later(1, 'foo', [0 => "someData", "attempts" => 1], 'default')->shouldBeCalled();
$this->release(1);
}
示例3: getChannel
/**
* Creates (if not yet created) and returns an AMQP channel.
*
* @return \PhpAmqpLib\Channel\AMQPChannel
*/
protected function getChannel()
{
if (null === $this->channel) {
$this->channel = $this->connection->channel();
$this->channel->queue_declare($this->queueName, false, false, false, false);
$this->channel->basic_qos(null, 1, null);
}
return $this->channel;
}
示例4: getAmqpChannel
/**
* @return AMQPChannel
*/
public function getAmqpChannel()
{
if ($this->amqp_channel) {
return $this->amqp_channel;
}
$this->amqp_channel = $this->connection->getAmqpConnection()->channel();
$this->amqp_channel->queue_declare($this->queue_config['queue_name'], false, $is_durable = true, false, false);
$this->amqp_channel->basic_qos(null, $this->queue_config['fetch_count'], null);
return $this->amqp_channel;
}
示例5: testDestruct
public function testDestruct()
{
$this->channelMock->expects($this->once())->method('close');
$this->clientMock->expects($this->once())->method('close');
$queue = new MessageQueue($this->clientMock);
unset($queue);
}
示例6: publishWithAMQP
/**
* @param DomainMessage $domainMessage
*/
private function publishWithAMQP(DomainMessage $domainMessage)
{
$payload = $domainMessage->getPayload();
$eventClass = get_class($payload);
$this->logger->info("publishing message with event type {$eventClass} to exchange {$this->exchange}");
$this->channel->basic_publish($this->messageFactory->createAMQPMessage($domainMessage), $this->exchange);
}
示例7: setupConnection
protected function setupConnection()
{
Yii::trace('Connecting to broker...', __METHOD__);
$this->connection = new AMQPConnection($this->host, $this->port, $this->user, $this->password, $this->vhost, $this->insist, $this->login_method, $this->login_response, $this->locale, $this->connection_timeout, $this->read_write_timeout, $this->context);
$this->channel = $this->connection->channel();
$this->channel->queue_declare($this->queue, false, true, false, false);
}
示例8: close
/**
* Close the running connection
*/
public function close()
{
if (null !== $this->connection && $this->connection->isConnected()) {
$this->channel->close();
$this->connection->close();
}
}
示例9: testQueueDeclaration
/**
* Test declaring a queue on the channel using the configured queue name
*/
public function testQueueDeclaration()
{
$qName = 'queue_name';
$this->setStubConfigData(['getQueueName' => $qName, 'getQueueConfiguration' => ['queue' => $qName, 'passive' => false, 'durable' => true, 'exclusive' => true, 'auto_delete' => true, 'nowait' => true]]);
$this->channel->expects($this->once())->method('queue_declare')->with($this->identicalTo($qName));
$this->invokeRestrictedMethod($this->amqpApi, 'declareQueue');
}
示例10: setUpAmqp
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.#');
}
示例11: consume
/**
* Consumes one event and calls callback for it.
*
* @param integer $timeout Optional timeout in seconds. Default is no timeout.
*
* @return void
*/
public function consume($timeout = 0)
{
try {
$this->channel->wait(null, false, $timeout);
} catch (AMQPTimeoutException $e) {
return;
}
}
示例12: getChannel
private function getChannel()
{
if ($this->channel) {
return $this->channel;
}
$this->channel = $this->connection->channel();
$this->channel->queue_declare($this->queue, false, false, false, false);
return $this->channel;
}
示例13: __destruct
/**
* Destructor.
*
* Closes RabbitMQ connection and channel if necessary.
*/
public function __destruct()
{
if ($this->channel) {
$this->channel->close();
}
if ($this->connection) {
$this->connection->close();
}
}
示例14: __destroy
public function __destroy()
{
if ($this->_channel) {
$this->_channel->close();
}
if ($this->getConnection && $this->getConnection->isConnected()) {
$this->getConnection->close();
}
}
示例15: tearDown
public function tearDown()
{
if ($this->ch2) {
$this->ch2->close();
}
if ($this->conn) {
$this->conn->close();
}
}