[rabbitmq-discuss] How to persist message when mq server restarts?
Simon MacMullen
simon at rabbitmq.com
Fri Mar 16 10:36:43 GMT 2012
On 16/03/12 10:18, cheepu wrote:
> Messages are persistent when the server is running but when I restart the
> server all the published messages are lost. For now there are no consumer
> running.
You are not using confirms or transactions - therefore you are telling
RabbitMQ that the messages should be persisted, but not that there is
any rush to do so. And RabbitMQ 2.7.1 will really not rush to do so in
this situation.
The upcoming 2.8.0 release will be more aggressive about persisting
messages in the absence of confirms / tx, but there is always the
possibility of message loss if you are just asking RabbitMQ to persist
the messages, but not tell you when it has done so.
I would suggest that you either:
* Wrap a batch of publishes in a transaction. When the transaction has
committed, you know the messages are on disc.
* Switch on confirm mode, and every so often invoke the convenience
method Channel.waitForConfirms(). When this has returned, you know the
messages are on disc.
* For best performance, switch on confirm mode and add a confirm
listener to your channel. You will then get notified whenever a message
or batch of messages makes it to disc.
Cheers, Simon
--
Simon MacMullen
RabbitMQ, VMware
More information about the rabbitmq-discuss
mailing list