[rabbitmq-discuss] Durable exchanges

Matthias Radestock matthias at lshift.net
Tue Jan 13 00:12:55 GMT 2009


Valentino Volonghi wrote:
> I'm wondering if they have any difference at all with non durable ones
> in rabbitmq.

There is a difference between durable and non-durable exchanges. The 
former survive a broker restart. The latter don't.

> The reason why I'm asking is because I want to change the least
> possible in the rabbitmq-erlang-client and I see that it supports 
> declaring durable queues easily but not durable exchanges easily.

amqp_channel:call(Channel, #'exchange.declare'{exchange = Name,
                                                durable = true}).

That's pretty easy, isn't it?

> Considering this I've tried creating a non durable exchange with a durable
> queue and persistent messages and to my "surprise" even after consuming
> all the messages in the queue I was still able to access the queue with the
> messages even through restarts.

Exchanges route published messages to bound queues. You can consume 
messages from queues without the presence of an exchange.

> This is a small part of the consumer:
>     ch.exchange_declare(exchange, type='topic', auto_delete=False)
>     qname, _, _ = ch.queue_declare(queue, durable=True, auto_delete=False)
>     ch.queue_bind(queue, exchange, routing_key=sys.argv[2])
>     ch.basic_consume(queue, callback=callback)

The above should fail at the bind step: the AMQP 0-8 spec requires that 
durable queues can only be bound to durable exchanges (NB: this changes 
in 0-9-1). And the RabbitMQ server definitely enforces that.

Could you perhaps start from a clean RabbitMQ instance, run the above 
through the tracer (http://www.rabbitmq.com/examples.html#tracer) and 
post the output (along with the complete code you ran)? That way we can 
tell whether the it's the client or the server that is at fault here.



More information about the rabbitmq-discuss mailing list