[rabbitmq-discuss] using ttl and dead-letter-exchange to retry after a delay, in PHP

Dave Alan Caruana dave at caruana.biz
Tue Oct 1 12:39:51 BST 2013

hello, I am trying to use dead-letter-exchange to create a 'delayed' queue,
basically my application takes input from an MQ and then posts the data 
(using curl) to an external website.
If the post operation fails I want it to wait a set amount of time and 
The idea is to publish these failed tries to a 'dead' queue with no 
consumer but with a timeout set up.
On expiry of the timeout, RabbitMQ should transfer these messages to the 
dead-letter-exchange which would be the original queue.

my code is currently here :

  public function publish_delay($data=false) {

    $connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
    $channel = $connection->channel();
                       "x-dead-letter-exchange" => array("S", 
                       "x-message-ttl" => array("I", 5000),
                       "x-expires" => array("I", 6000)
    $msg = new AMQPMessage($data);

$msg -> is the message I want sent with a delay
$this->channelname would be the channel I want it to go to after the delay
'errorXchange' is the dead queue with the ttl & no consumer.

Currently nothing is coming through on $this->channelname (where there is a 
consumer, of course).
I haven't understood how to debug rabbitmq or what is going wrong, and 
there is precious little documentation!

help would be VERY welcome!

Dave in Malta.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20131001/a714e98e/attachment.htm>

More information about the rabbitmq-discuss mailing list