[rabbitmq-discuss] Persisting Data

Matthias Radestock matthias at lshift.net
Tue Dec 25 10:54:03 GMT 2007


Varun,

Varun Samuel wrote:
> I wrote a small program to create and send persistent messages to a
> durable queue. Once it had sent the messages it would try to read
> them immediately using basicGet. This seems to be the problem. Once I
> had a separate client try to read the messages, everything was fine.
> But one program sending messages to the queue then immediately trying
> to read them doesn't work.

basic.publish is an asynchronous operation. There is no way to tell when 
the messages thus published will be available via basic.get. Whether you 
perform the publish and get on the same or different connections does 
not change that, but it does alter the timing, which means you can (but 
are not guaranteed to) get different results.

> With regards to the other issue- reading the last n messages in a  
> queue, you wrote:
> 
> ---
> To simulate a last-value cache, you could write a simple "replay"
> service that keeps a log of recent chat messages, and sends them out
> when asked by a new chat participant.
> ---
> 
> I wasn't sure if you meant this was done inside rabbitmq. I just  
> settled on sticking every sent message in a LIFO data
> structure, outside of rabbitmq. Any client connecting to rabbitmq  
> would first get the messages from that
> 
> This is a very basic way to do it. I read a bit of the AMQP spec and  
> didn't see anything about doing it in there. Does the
> method you describe make use of rabbitmq to log recent chat messages?

What you implemented is exactly what Tony suggested. There is no way to 
do this inside AMQP 0-8/9. AMQP 0-10 will offer queue browsing, allowing 
clients to read messages from a queue without consuming them. There have 
also been some discussions in the working group about supporting last 
value caches more directly.

> Thanks, and Happy Holidays!

Thank you, and the same to you.


Matthias.




More information about the rabbitmq-discuss mailing list