當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。