[rabbitmq-discuss] TTL on Consumers in PHP
Michael Klishin
mklishin at gopivotal.com
Wed Jun 25 04:31:51 BST 2014
On 25 June 2014 at 00:43:15, Sean Joyce (sean.joyce at patientco.com) wrote:
> > I've been trying to figure out where to call basic_cancel in
> this code, but not finding the right solution. Any tips on how
> to refactor and get what I want?
>
> public function consume() {
> $callback = function($msg) {
> $pMsg = new ProcessorMessage();
> $pMsg->onMessage($msg->body);
> $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
> };
>
> $this->channel->basic_qos(null, 1, null);
> $this->channel->basic_consume($queue_name, '', false,
> false, false, false, $callback);
>
> while(count($this->channel->callbacks)) {
> $this->channel->wait();
> }
>
> }
Sean,
Take a look at the following 2 examples:
https://github.com/videlalvaro/php-amqplib/blob/master/demo/amqp_consumer_non_blocking.php
https://github.com/videlalvaro/php-amqplib/blob/master/demo/amqp_consumer.php#L52-54
--
MK
Staff Software Engineer, Pivotal/RabbitMQ
More information about the rabbitmq-discuss
mailing list