Yes, here's how:
$amqp = new AMQPConnection($your_connection_params); $amqp->setTimeout($seconds);
Then, when you call consume () in the queue, if no messages arrive during the waiting period, an AMQPException will be thrown from consume () with the message "Resource temporarily unavailable." If you ever exit consumption () or time out, be sure to call cancel () on the queue object to correctly reset the consumer. To do this, you need to create a globally unique consumer tag and pass it as an undocumented third parameter for consumption:
$tag = uniqid() . microtime(true); $queue->consume($callback, $flags, $tag); $queue->cancel($tag);
That way, you can call consume () again later without any weird problems that will make your head spin.
gurumike
source share