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


PHP AMQPChannel::basic_cancel方法代码示例

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


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

示例1: 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

示例2: consume

 /**
  * Listener for the queue
  * @param string $consumer_url
  * @param array $post_vars
  */
 public function consume($consumer_url, $post_vars = array())
 {
     $this->consumer_url = $consumer_url;
     $this->consumer_post = $post_vars;
     if ($this->consumer_count < $this->consumer_max) {
         $this->consumer_start = time();
         $callback = function (AMQPMessage $message) {
             $post_vars = $this->consumer_post;
             $post_vars['url'] = $this->consumer_url;
             $post_vars['queue'] = $this->queue;
             $post_vars['message'] = $message->body;
             $response = $this->httpRequest->post($this->consumer_url, $post_vars);
             $code = $this->httpRequest->statusCode();
             if ($code == 200) {
                 $message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']);
             } else {
                 // log the error to a file
                 $log_message = $code . "\n\n";
                 $log_message .= $message->body . "\n\n";
                 $log_message .= print_r($message, true);
                 $log_message .= "\n\n\n";
                 $log_message .= print_r($response, true);
                 Log::error($log_message);
             }
             if ($this->consumer_start + $this->ttl < time()) {
                 $this->channel->basic_cancel($message->delivery_info['consumer_tag']);
             }
         };
         $this->channel->basic_consume($this->queue, '', false, false, false, false, $callback);
         while (count($this->channel->callbacks)) {
             $this->channel->wait();
         }
     }
 }
开发者ID:alistairshaw,项目名称:ambitiousmail-relay,代码行数:39,代码来源:RabbitMQQueue.php

示例3: basicCancel

 /**
  * @param MessageInterface $message
  *
  * @throws ConnectorException
  */
 public function basicCancel(MessageInterface $message)
 {
     /** @var AMQPMessage $amqpMessage */
     $amqpMessage = $message->getOriginalMessage();
     if (!$amqpMessage instanceof AMQPMessage) {
         throw ConnectorException::invalidOriginalMessageType(AMQPMessage::class, get_class($message));
     }
     $this->channel->basic_cancel($amqpMessage->delivery_info['consumer_tag']);
     $this->logger->info(sprintf('Message consumption stopped!'));
 }
开发者ID:retrinko,项目名称:cottontail,代码行数:15,代码来源:PhpAmqpLibConnector.php

示例4: work

 /**
  * Start listen queue for tasks
  *
  * @param int $processMessages max number of messages for processing
  *
  * @return Generator
  */
 public function work(int $processMessages = null) : Generator
 {
     $this->messagesProcessed = 0;
     while (count($this->channel->callbacks)) {
         $this->channel->wait();
         if ($this->lastResult instanceof Result) {
             (yield $this->lastResult);
             $this->lastResult = null;
             $this->messagesProcessed++;
         }
         if (null !== $processMessages && $this->messagesProcessed >= $processMessages) {
             break;
         }
     }
     $this->channel->basic_cancel($this->consumerTag);
 }
开发者ID:turboezh,项目名称:yii2-task-queue,代码行数:23,代码来源:Worker.php

示例5: createReplyConsumer

 /**
  * @return string
  */
 private function createReplyConsumer()
 {
     $tag = uniqid('reply-consumer-');
     $this->channel->basic_consume(self::REPLY_QUEUE, $tag, false, true, false, false, function (AMQPMessage $message) {
         if (!($id = $message->get('correlation_id'))) {
             return;
         }
         if (!isset($this->unresolved[$id])) {
             return;
         }
         $this->unresolved[$id]->setReply($message);
         unset($this->unresolved[$id]);
         if (empty($this->unresolved)) {
             $this->channel->basic_cancel($message->delivery_info['consumer_tag']);
             $this->consumer = null;
         }
     });
     return $tag;
 }
开发者ID:skolodyazhnyy,项目名称:message-bus-client,代码行数:22,代码来源:Invoker.php

示例6: cancelConsumer

 /**
  * Cancel a specific consumer.
  *
  * @param string $consumerId
  *
  * @return $this
  */
 public function cancelConsumer($consumerId)
 {
     $this->channel->basic_cancel($consumerId);
     return $this;
 }
开发者ID:znk3r,项目名称:mqlib,代码行数:12,代码来源:Channel.php


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