本文整理汇总了PHP中AMQPQueue::nack方法的典型用法代码示例。如果您正苦于以下问题:PHP AMQPQueue::nack方法的具体用法?PHP AMQPQueue::nack怎么用?PHP AMQPQueue::nack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AMQPQueue
的用法示例。
在下文中一共展示了AMQPQueue::nack方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nack
/**
* Mark a message as explicitly not acknowledged.
* RabbitMQ supports the nack method that provides all the functionality of
* basic.reject whilst also allowing for bulk processing of messages.
* To reject messages in bulk, clients set the multiple flag of the basic.nack method
* to true. The broker will then reject all unacknowledged, delivered messages up to
* and including the message specified in the delivery_tag field of the
* basic.nack method. In this respect, basic.nack complements the bulk acknowledgement
* semantics of basic.ack.
*
* @param integer $flags AMQP_MULTIPLE to nack all previous unacked messages as well.
* AMQP_REQUEUE to requeue the message(s),
*
* @return bool
*/
public function nack($flags = AMQP_REQUEUE)
{
if (!$this->consumed) {
return $this->consumed = $this->queue->nack($this->getDeliveryTag(), $flags);
}
return $this->consumed;
}
示例2: nack
/**
* @param string $deliveryTag
* @param int $flags
*
* @return bool
*/
public function nack($deliveryTag, $flags = Client::NOPARAM)
{
try {
return $this->rawQueue->nack($deliveryTag, $flags);
} catch (\Exception $e) {
ClientHelper::throwRightException($e);
}
}
示例3: nack
/**
* @inheritdoc
*/
public function nack(int $deliveryTag, int $flags = Constants::AMQP_NOPARAM)
{
$this->queue->nack($deliveryTag, $flags);
}
示例4: nack
/**
* @inheritdoc
*/
public function nack($deliveryTag, $flags = AMQP_NOPARAM)
{
$this->delegate->nack($deliveryTag, self::convertToDelegateFlags($flags));
}
示例5: nack
/**
* {@inheritDoc}
*/
public function nack(Message $message, $requeue = false)
{
$this->queue->nack($message->getId(), $requeue ? AMQP_REQUEUE : null);
}
示例6: 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;
}
}