当前位置: 首页>>代码示例>>PHP>>正文


PHP AMQPChannel::basic_consume方法代码示例

本文整理汇总了PHP中PhpAmqpLib\Channel\AMQPChannel::basic_consume方法的典型用法代码示例。如果您正苦于以下问题:PHP AMQPChannel::basic_consume方法的具体用法?PHP AMQPChannel::basic_consume怎么用?PHP AMQPChannel::basic_consume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhpAmqpLib\Channel\AMQPChannel的用法示例。


在下文中一共展示了AMQPChannel::basic_consume方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: consume

 public function consume(ConsumerInterface $consumer, $callback)
 {
     $this->channel->basic_consume($consumer->getName(), '', false, false, false, false, $callback);
     while (count($this->channel->callbacks)) {
         $this->channel->wait();
     }
 }
开发者ID:roryy,项目名称:flatfishqueue,代码行数:7,代码来源:Channel.php

示例2: waitingForCall

 public function waitingForCall()
 {
     $this->channel->basic_consume(self::QUEUE_NAME, '', false, false, false, false, array($this, 'receive'));
     while (count($this->channel->callbacks)) {
         $this->channel->wait();
     }
 }
开发者ID:eugenegp,项目名称:uzticketstat,代码行数:7,代码来源:RabbitMq.php

示例3: listen

 /**
  * Infinite loop: Listens for messages from the queue and sends them to the callback.
  *
  * @param callback $callback
  */
 public function listen($callback)
 {
     $this->channel->basic_qos(null, 1, null);
     $this->channel->basic_consume(self::QUEUE_NAME, '', false, true, false, false, $callback);
     while ($this->channel->callbacks) {
         $this->channel->wait();
     }
 }
开发者ID:picahielos,项目名称:mtp,代码行数:13,代码来源:MessageQueue.php

示例4: consume

 /**
  * @param string $exchangeName
  * @param callable $callback
  */
 public function consume($exchangeName, callable $callback)
 {
     $this->callback = $callback;
     $this->channel->basic_consume($exchangeName, '', false, true, false, false, [$this, 'callback']);
     while (count($this->channel->callbacks)) {
         $this->channel->wait();
     }
 }
开发者ID:zoek1,项目名称:php-testing-tools,代码行数:12,代码来源:AmqpMessageConsumer.php

示例5: consume

 public function consume()
 {
     $queue = $this->initialize();
     $tag = $this->handler->name();
     $this->channel->basic_consume($queue, $tag, false, false, false, false, [$this, 'handle']);
     while (isset($this->channel->callbacks[$tag])) {
         $this->channel->wait();
     }
 }
开发者ID:skolodyazhnyy,项目名称:message-bus-client,代码行数:9,代码来源:Consumer.php

示例6: testSendFile

 public function testSendFile()
 {
     $this->msg_body = file_get_contents(__DIR__ . '/fixtures/data_1mb.bin');
     $msg = new AMQPMessage($this->msg_body, array('delivery_mode' => 1));
     $this->ch->basic_publish($msg, $this->exchange_name, $this->queue_name);
     $this->ch->basic_consume($this->queue_name, '', false, false, false, false, array($this, 'process_msg'));
     while (count($this->ch->callbacks)) {
         $this->ch->wait();
     }
 }
开发者ID:vongrad,项目名称:loanbroker,代码行数:10,代码来源:FileTransferTest.php

示例7: testPublishConsume

 public function testPublishConsume()
 {
     $this->msg_body = 'foo bar baz äëïöü';
     $msg = new AMQPMessage($this->msg_body, array('content_type' => 'text/plain', 'delivery_mode' => 1, 'correlation_id' => 'my_correlation_id', 'reply_to' => 'my_reply_to'));
     $this->ch->basic_publish($msg, $this->exchange_name, $this->queue_name);
     $this->ch->basic_consume($this->queue_name, getmypid(), false, false, false, false, array($this, 'process_msg'));
     while (count($this->ch->callbacks)) {
         $this->ch->wait();
     }
 }
开发者ID:vongrad,项目名称:loanbroker,代码行数:10,代码来源:AbstractPublishConsumeTest.php

示例8: setUp

 /**
  * Set up AMQP connection.
  */
 public function setUp()
 {
     $container = $this->getContainer();
     $exchangeName = 'general';
     $connection = new AMQPConnection($container->getParameter('ongr_task_messenger.publisher.default.amqp.host'), $container->getParameter('ongr_task_messenger.publisher.default.amqp.port'), $container->getParameter('ongr_task_messenger.publisher.default.amqp.user'), $container->getParameter('ongr_task_messenger.publisher.default.amqp.password'));
     $this->channel = $connection->channel();
     list($queueName, , ) = $this->channel->queue_declare();
     $this->channel->queue_bind($queueName, $exchangeName, explode('.', gethostname())[0]);
     $this->channel->basic_consume($queueName, getmypid(), false, true, true, true, [$this, 'verifyMessage']);
 }
开发者ID:GrandLTU,项目名称:TaskMessengerBundle,代码行数:13,代码来源:AMQPPublisherTest.php

示例9: initialize

 /**
  * Create consumer.
  */
 private function initialize()
 {
     $this->messages = [];
     list($queue) = $this->channel->queue_declare('', false, false, true, true);
     $this->channel->queue_bind($queue, $this->exchange);
     $this->channel->basic_consume($queue, '', false, false, false, false, function (AMQPMessage $message) {
         $this->messages[] = $message;
         $this->channel->basic_cancel($message->delivery_info['consumer_tag']);
     });
 }
开发者ID:skolodyazhnyy,项目名称:message-bus-client,代码行数:13,代码来源:AMQPClientTest.php

示例10: consume

 /**
  * @param string $queue
  * @param string $exchange
  * @param string $routingKey
  * @param callable $callback
  */
 public function consume($queue, $exchange, $routingKey, $callback)
 {
     $this->declareComponents($routingKey, $exchange, $queue);
     $this->channel->basic_consume($queue, '', false, false, false, false, function ($amqpMessage) use($callback) {
         $message = new Message($amqpMessage);
         $callback($message);
     });
     while (count($this->channel->callbacks)) {
         $this->channel->wait();
     }
 }
开发者ID:ajouve,项目名称:rabbit-mq-wrapper,代码行数:17,代码来源:Client.php

示例11: consume

 /**
  * @param callable $callback
  * @return void
  */
 public function consume(callable $callback)
 {
     $internCallback = function ($msg) use($callback) {
         //echo " [x] Received ", $msg->body, "\n";
         $callback(unserialize($msg->body));
     };
     $this->exchange->basic_consume($this->exchangeName, '', false, true, false, false, $internCallback);
     while (count($this->exchange->callbacks)) {
         $this->exchange->wait();
     }
 }
开发者ID:wildpascal,项目名称:remote-event-dispatcher,代码行数:15,代码来源:AmqpHandler.php

示例12: wait

 /**
  * {@inheritdoc}
  */
 public function wait(Closure $callback)
 {
     $this->channel->basic_consume($this->queue, '', false, true, false, false, function ($rabbitMessage) use($callback) {
         $message = $this->serializer->unserialize($rabbitMessage->body);
         $callback($message);
         $rabbitMessage->delivery_info['channel']->basic_ack($rabbitMessage->delivery_info['delivery_tag']);
     });
     while (count($this->channel->callbacks)) {
         $this->channel->wait();
     }
 }
开发者ID:tomaj,项目名称:hermes,代码行数:14,代码来源:RabbitMqDriver.php

示例13: testFrameOrder

 public function testFrameOrder()
 {
     $msg = new AMQPMessage('');
     $hdrs = new AMQPTable(array('x-foo' => 'bar'));
     $msg->set('application_headers', $hdrs);
     for ($i = 0; $i < $this->msg_count; $i++) {
         $this->ch->basic_publish($msg, $this->exchange_name, $this->queue_name);
     }
     $this->ch2->basic_consume($this->queue_name, '', false, true, false, false, array($this, 'process_msg'));
     while (count($this->ch2->callbacks)) {
         $this->ch2->wait();
     }
 }
开发者ID:CarsonF,项目名称:php-amqplib,代码行数:13,代码来源:Bug256Test.php

示例14: thereShouldBeAMessageInQueue

 /**
  * @Then there should be a message in queue :queue
  *
  * @param              $queue
  * @param PyStringNode $string
  */
 public function thereShouldBeAMessageInQueue($queue, PyStringNode $string = null)
 {
     $expected = $string ? $string->getRaw() : null;
     if (null === $expected) {
         $this->channel->basic_consume($queue);
     } else {
         $consumer = function (AMQPMessage $message) use($expected) {
             $this->channel->basic_ack($message->delivery_info['delivery_tag']);
             Assert::that($message->body)->equal($expected);
         };
         $this->channel->basic_consume($queue, '', false, false, false, false, $consumer);
     }
     $this->channel->wait(null, false, 4);
 }
开发者ID:DrSchimke,项目名称:Lepus,代码行数:20,代码来源:LepusContext.php

示例15: process_msg1

 public function process_msg1($msg)
 {
     $delivery_info = $msg->delivery_info;
     $this->q1msgs++;
     if ($this->q1msgs < 2) {
         $this->ch2->basic_consume($this->queue_name2, "", false, true, false, false, array($this, 'process_msg2'));
     }
     while (count($this->ch2->callbacks)) {
         $this->ch2->wait();
     }
     if ($this->q1msgs == 2) {
         $delivery_info['channel']->basic_cancel($delivery_info['consumer_tag']);
     }
 }
开发者ID:adridev,项目名称:php-amqplib,代码行数:14,代码来源:Bug40Test.php


注:本文中的PhpAmqpLib\Channel\AMQPChannel::basic_consume方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。