[rabbitmq-discuss] Persisting Messages on a Direct Exchange, Selectively Looking for Particular Messages

McMahon, James S (TASC) james.mcmahon at TASC.COM
Thu Feb 16 12:08:35 GMT 2012


Thank you for taking the time to reply, Emile. This is very helpful. I understand now that my exchange is exclusively for routing. Can I ask you a few follow up questions?

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?

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?

Thank you again for your help. If I can see an example I will be off to the races this evening, refining my initial code.

-Jim


________________________________________
From: Emile Joubert [emile at rabbitmq.com]
Sent: Thursday, February 16, 2012 6:01 AM
To: McMahon, James S (TASC)
Cc: rabbitmq-discuss at lists.rabbitmq.com
Subject: Re: [rabbitmq-discuss] Persisting Messages on a Direct Exchange, Selectively Looking for Particular Messages

Hi James,

On 16/02/12 00:45, McMahon, James S (TASC) wrote:
> How would one persist messages on the directed exchange? I want to do

You can guarantee that messages are persisted by declaring queues as
durable and setting the delivery-mode to 2. The exchange plays no part
in determining whether a message will be persisted.

> My messages are directed to exchanges by a qmsgTarget field. My messages
> have a field in their structure called srcId. My messages also have a
> field in their structure called seqNum. Thus a consumer may wish to say
> "Please get me message 3 from srcid 666 from the qmsgtarget Server
> direct exchange". Another consumer may later issue the same request, so
> this third message in the sequence for srcid 666 must remain on the
> directed exchange.

Messages are stored in queues, and exchanges maintain no state. If you
need multiple consumers to receive the same message then you should
route the message to multiple queues (tutorial 3). If you need to route
messages based on headers then you will find the headers exchange useful:
http://www.rabbitmq.com/tutorials/amqp-concepts.html#exchange-headers

> I will be implementing a method deleteQmsg() that I intend to use to
> delete messages selectively.

Queues are not well suited to selective manipulation of messages beyond
the head of the queue. If the problem cannot be expressed in terms of
messaging then a relational database is more suitable for your purposes
than a message broker.



-Emile
CONFIDENTIALITY NOTICE: This message and any attachments or files transmitted with it (collectively, the "Message") are intended only for the addressee and may contain information that is privileged, proprietary and/or prohibited from disclosure by law or contract. If you are not the intended recipient: (a) please do not read, copy or retransmit the Message; (b) permanently delete and/or destroy all electronic and hard copies of the Message; (c) notify us by return email; and (d) you are hereby notified that any dissemination, distribution or copying of the Message is strictly prohibited.


More information about the rabbitmq-discuss mailing list