Reputation: 2441
I checked "Message durability" part of RabbitMQ tutorial. But it has this note:
Marking messages as persistent doesn't fully guarantee that a message won't be lost. Although it tells RabbitMQ to save the message to disk, there is still a short time window when RabbitMQ has accepted a message and hasn't saved it yet. Also, RabbitMQ doesn't do fsync(2) for every message -- it may be just saved to cache and not really written to the disk
But what if I need really durable queue? Which best practices can I to use? Should I have "queue" in database and some "resender" by cron if, for example, message wasn't ACK'ed in 2 minutes? Are there some better solutions?
Also, what if my consumer crashed after it processed message and before it sent ACK?
UPD: my question was marked as "possible duplicate" of clustering question. I have no idea how clusters can help to solve these problems.
Upvotes: 0
Views: 1362
Reputation: 22750
Please read here about Guaranteed Delivery with Tx
The publisher would use something like:
ch.txSelect();
ch.basicPublish("", QUEUE_NAME,MessageProperties.PERSISTENT_BASIC,"nop".getBytes());
ch.txCommit();
Note: This can kill your performance application!
EDIT
Read also "Publisher Confirms" https://www.rabbitmq.com/confirms.html as suggesgted by @old_sound
Upvotes: 2
Reputation: 2313
Take a look at Publisher Confirms that are made to address the problem of knowing if RabbitMQ has persisted/replicated your message or not: https://www.rabbitmq.com/confirms.html
Upvotes: 1