[rabbitmq-discuss] Persisting Messages on a Direct Exchange, Selectively Looking for Particular Messages
emile at rabbitmq.com
Thu Feb 16 13:12:26 GMT 2012
On 16/02/12 12:08, McMahon, James S (TASC) wrote:
> Is there an example you can direct me towards that shows the Java
> implementation to guarantee that messages are persisted by declaring
> queues as durable and setting the delivery-mode to 2?
The com.rabbitmq.examples.StressPersister example in the Java client
exercises persistence in the broker and illustrates the steps necessary
to guarantee that messages are persisted.
> So assuming that I use my direct exchange to route messages to
> appropriate queues, and my queues are declared as durable with
> delivery-mode 2, then multiple consumers will see those messages on
> that queue regardless of whether they were connected at the time the
> message was published to that queue through the direct exchange?
No, persistence in this context means that the message is on durable
storage on the broker and recoverable in case the broker crashes.
If you want consumers to be able to retrieve messages that were
published in their absence then you must arrange for queues to be
declared and bound before publishing starts. It will take some
coordination between the consumers and the party that performs this
preliminary setup to ensure that consumers know the name of their queue.
More information about the rabbitmq-discuss