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


PHP AMQPQueue::ack方法代码示例

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


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

示例1: ack

 /**
  * This method allows the acknowledgement of a message that is retrieved without
  * the AMQP_AUTOACK flag through AMQPQueue::get() or AMQPQueue::consume()
  *
  * @return bool
  */
 public function ack()
 {
     if (!$this->consumed) {
         return $this->consumed = $this->queue->ack($this->getDeliveryTag());
     }
     return $this->consumed;
 }
开发者ID:gallna,项目名称:amqp-event,代码行数:13,代码来源:ConsumeEvent.php

示例2: process

 /**
  * @param \AMQPEnvelope            $envelope
  * @param \AMQPQueue               $queue
  * @param PushPipe                 $pushPipe
  * @param string                   $errorQueue
  * @param ReceiveCancellationToken $cancellationToken
  * @param EndpointControlToken     $endpointControlToken
  *
  * @return bool
  */
 public function process(\AMQPEnvelope $envelope, \AMQPQueue $queue, PushPipe $pushPipe, $errorQueue, ReceiveCancellationToken $cancellationToken, EndpointControlToken $endpointControlToken)
 {
     try {
         $messageId = '';
         $headers = [];
         $pushMessage = false;
         try {
             $messageId = $this->messageConverter->retrieveMessageId($envelope);
             $headers = $this->messageConverter->retrieveHeaders($envelope);
             $pushMessage = true;
         } catch (\Exception $e) {
             $this->routingTopology->sendToQueue($this->brokerModel, $errorQueue, $envelope->getBody(), ['headers' => $envelope->getHeaders()]);
         }
         if ($pushMessage) {
             $pushPipe->push(new PushContext($messageId, $headers, $envelope->getBody() ?: '', $cancellationToken, $endpointControlToken));
         }
         if ($cancellationToken->isCancellationRequested()) {
             $queue->reject($envelope->getDeliveryTag(), AMQP_REQUEUE);
         } else {
             $queue->ack($envelope->getDeliveryTag());
         }
     } catch (CriticalErrorException $e) {
         // just ... die
         throw $e;
     } catch (\Exception $e) {
         $queue->reject($envelope->getDeliveryTag(), AMQP_REQUEUE);
     }
     if ($endpointControlToken->isShutdownRequested()) {
         return false;
     }
     return true;
 }
开发者ID:phpservicebus,项目名称:core,代码行数:42,代码来源:MessageProcessor.php

示例3: ack

 /**
  * @param string $deliveryTag
  * @param int    $flags
  *
  * @return bool
  */
 public function ack($deliveryTag, $flags = Client::NOPARAM)
 {
     try {
         return $this->rawQueue->ack($deliveryTag, $flags);
     } catch (\Exception $e) {
         ClientHelper::throwRightException($e);
     }
 }
开发者ID:csharpru,项目名称:yii2-amqp,代码行数:14,代码来源:Queue.php

示例4: read

 /**
  * @param \AMQPQueue $queue
  * @return bool|string
  */
 public static function read(\AMQPQueue $queue)
 {
     usleep(10000);
     $envelope = $queue->get(\AMQP_NOPARAM);
     if ($envelope) {
         $message = $envelope->getBody();
         $queue->ack($envelope->getDeliveryTag());
         return $message;
     }
     return false;
 }
开发者ID:zarincheg,项目名称:celium,代码行数:15,代码来源:Rabbit.php

示例5: publish

 /**
  * @param \AMQPEnvelope $envelope
  * @param \AMQPQueue $queue
  * @param string $m
  */
 public function publish($envelope, $queue, $m)
 {
     if ($m instanceof AmqpResp) {
         $m = Json::encode($m->getData());
     } elseif (is_object($m) || is_array($m)) {
         $m = Json::encode($m);
     }
     $chanel = $this->getChanel();
     // Точка доступа
     // Точка обмена
     $exchange = new \AMQPExchange($chanel);
     $exchange->setFlags(AMQP_AUTODELETE | AMQP_DURABLE);
     $attributes = array('correlation_id' => $envelope->getCorrelationId());
     $routingKey = $envelope->getReplyTo();
     if ($exchange->publish($m, $routingKey, AMQP_NOPARAM, $attributes)) {
         $queue->ack($envelope->getDeliveryTag());
     }
 }
开发者ID:andriell,项目名称:yii2-amqp,代码行数:23,代码来源:AmqpConsumer.php

示例6: callback

 function callback(AMQPEnvelope $message, AMQPQueue $q)
 {
     //say that message received
     $q->ack($message->getDeliveryTag());
 }
开发者ID:inilotic,项目名称:vks_nodes_core,代码行数:5,代码来源:AMQBasicConsumer.class.php

示例7: AMQPConnection

$rabbit = new AMQPConnection(array('host' => '127.0.0.1', 'port' => '5672', 'login' => 'guest', 'password' => 'guest'));
$rabbit->connect();
$channel = new AMQPChannel($rabbit);
$queue = new AMQPExchange($channel);
$queue->setName('amq.direct');
/**
 * Добавляем очередь откуда будем брать страницы
 */
$q = new AMQPQueue($channel);
$q->setName('images_to_scan');
$q->declare();
$q->bind('amq.direct', 'analyze_image');
/**
 * Обрабатываем пока в очереди не закончатся сообщения
 */
while (true) {
    $image = $q->get();
    if ($image) {
        $url = $image->getBody();
        echo "Checking: {$url}\n";
        $analyzer = new ImageAnalyzer($url);
        /**
         * Если картинка еще не была проанализирована, обрабатываем и добавляем в индекс
         */
        $analyzer->analyze();
        $q->ack($image->getDeliveryTag());
    } else {
        sleep(1);
    }
}
$rabbit->disconnect();
开发者ID:stanislav-web,项目名称:phphighload.com,代码行数:31,代码来源:analyze_image.php

示例8: readAll

 /**
  * Read all messages
  *
  * @access public
  *
  * @param string $chat name chat room
  * @param string $route name route
  * @param string $nameReader name queue
  *
  * @return array
  * @throws \AMQPConnectionException
  * @throws \AMQPQueueException
  * @throws \AMQPChannelException
  */
 public function readAll($chat, $route, $nameReader)
 {
     $queue = new \AMQPQueue($this->channel);
     $queue->setName($nameReader);
     /** @noinspection PhpUndefinedMethodInspection */
     $queue->declare();
     $queue->bind($chat, $route);
     $result = [];
     while ($envelop = $queue->get()) {
         $queue->ack($envelop->getDeliveryTag());
         $result[] = $envelop;
     }
     return $result;
 }
开发者ID:linpax,项目名称:microphp-framework,代码行数:28,代码来源:RabbitMQ.php

示例9: AMQPConnection

$exchange_name = 'example.fanout';
$queue_name = 'example.fanout.default';
$route_key = 'ignored-for-fanout';
// establish connection
$connection = new AMQPConnection();
if (!$connection->connect()) {
    echo "Failed to establish connection", PHP_EOL;
    die;
}
// create channel
$channel = new AMQPChannel($connection);
// create exchange
$exchange = new AMQPExchange($channel);
$exchange->setType(AMQP_EX_TYPE_FANOUT);
$exchange->setName($exchange_name);
$exchange->declareExchange();
// if exchange already exists it will not be redeclared
// here we definitely need queue to be declared before we'll use it
$queue = new AMQPQueue($channel);
$queue->setName($queue_name);
$queue->declareQueue();
// same for queue, if already declared will not be redeclared
$queue->bind($exchange_name, $route_key);
// NOTE: if exchange doesn't exists you can't bind queue to it, which is
// although quite obvious
$queue->consume(function (AMQPEnvelope $envelope, AMQPQueue $queue) {
    $message = $envelope->getBody();
    echo "Received '{$message}' at " . date(DATE_RFC822), PHP_EOL;
    $queue->ack($envelope->getDeliveryTag());
});
开发者ID:pinepain,项目名称:amqpy,代码行数:30,代码来源:consumer.php

示例10: ack

 /**
  * @inheritdoc
  */
 public function ack(int $deliveryTag, int $flags = Constants::AMQP_NOPARAM)
 {
     $this->queue->ack($deliveryTag, $flags);
 }
开发者ID:prolic,项目名称:HumusAmqp,代码行数:7,代码来源:Queue.php

示例11: ack

 /**
  * @inheritdoc
  */
 public function ack($deliveryTag, $flags = null)
 {
     return $this->delegate->ack($deliveryTag, self::convertToDelegateFlags($flags));
 }
开发者ID:treehouselabs,项目名称:queue,代码行数:7,代码来源:Queue.php

示例12: ack

 /**
  * {@inheritDoc}
  */
 public function ack(Message $message)
 {
     $this->queue->ack($message->getId());
 }
开发者ID:kyar,项目名称:swarrot,代码行数:7,代码来源:PeclPackageMessageProvider.php

示例13: basic_ack

 /**
  * @param  string $deliveryTag
  * @return mixed
  */
 public function basic_ack($deliveryTag)
 {
     $this->queue->ack($deliveryTag);
 }
开发者ID:remi-san,项目名称:universal-amqp,代码行数:8,代码来源:AMQPExtensionChannel.php

示例14: consume

 /**
  * Consumes next message from queue and passes its payload to callback when it arrives
  *
  * @param string $queueName Queue name to consume message from
  * @param callable $callback Callback to pass payload to
  *
  * @throws \AMQPException
  */
 public function consume($queueName, callable $callback)
 {
     try {
         $queue = new \AMQPQueue($this->getChannel());
         $queue->setName($queueName);
         $queue->consume(function (\AMQPEnvelope $envelope, \AMQPQueue $queue) use($callback) {
             switch ($callback($envelope->getBody())) {
                 case self::MESSAGE_ACK:
                     $queue->ack($envelope->getDeliveryTag());
                     break;
                 case self::MESSAGE_NACK:
                     $queue->nack($envelope->getDeliveryTag());
                     break;
                 case self::MESSAGE_REQUEUE:
                     $queue->nack($envelope->getDeliveryTag(), AMQP_REQUEUE);
                     break;
             }
         });
     } catch (\AMQPException $e) {
         $this->channel = null;
         throw $e;
     }
 }
开发者ID:helminster,项目名称:imgloader,代码行数:31,代码来源:AMQPClient.php

示例15: removeMessage

 /**
  * Remove message from MQ
  * @param object $queue
  * @param array $inputArray
  * @return void
  * @access public
  */
 public function removeMessage(\AMQPQueue $queue, $inputArray = array())
 {
     $queue->bind($this->exchangeOptions['name'], $this->queueOptions['routing_key']);
     foreach ($inputArray as $deliveryTag) {
         if (isset($deliveryTag)) {
             $queue->ack($deliveryTag);
         }
     }
 }
开发者ID:ExSituMarketing,项目名称:EXS-silex-rabbitmq-provider,代码行数:16,代码来源:AmqpService.php


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