RabbitMQ - routing messages after they reach their expiration time
Question: I've recently found out RabbitMQ feature that allows you to delay messages and
it works great although I couldn't find any examples similar to what I need:

Let's say there are 3 types of messages: A, B and C. We've got 2 delay_queues
with 1 hour and 2 hours `'x-message-ttl` values. There are also 3 types of
destination_queues - each for specific message type.

What I would like to achieve is after the message in one of the delay_queues
reaches its TTL it's going to be routed to one of the destination_queues
depending on its type. Something like this:

![enter image description here](http://i.stack.imgur.com/soqVk.jpg)

Is this even possible using RabbitMQ message properties? Any ideas? My code
sending messages to the delay queue (after expiration they're sent to hello
queue):

    
    
    #!/usr/bin/env python
    import pika
    
    connection = pika.BlockingConnection(pika.ConnectionParameters(
                   'localhost'))
    
    channel = connection.channel()
    channel.confirm_delivery()
    channel.queue_declare(queue='hello', durable=True)
    
    channel.queue_bind(exchange='amq.direct',
                       queue='hello')
    
    delay_channel = connection.channel()
    delay_channel.confirm_delivery()
    
    delay_channel.queue_declare(queue='hello_delay', durable=True,  arguments={
      'x-message-ttl' : 3600000,
      'x-dead-letter-exchange' : 'amq.direct',
      'x-dead-letter-routing-key' : 'hello'
    })
    
    while 1 :
            delay_channel.basic_publish(exchange='',
                          routing_key='hello_delay',
                          body="test",
                          properties=pika.BasicProperties(delivery_mode=2))
            print "Sent to delay queue"
    


Answer: When messages expire because they reach the imposed TTL, they can be
redirected to a [dead-letter exchange](https://www.rabbitmq.com/dlx.html),
that's what I think you are using implicitly to move messages to a further
queue after they are expired.

You can select different destination queues by using the original routing-keys
of the messages, or eventually "CC" and "BCC" message headers.

