Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rabbitmq queue clear after restart

I have installed RabbitMQ on windows server 2012 64 Bit.

I Tested Publishing And Consuming Parts with Huge Data Everything is fine, the only problem i am facing is the messages in a queue are getting lost after RabbitMQServer restart.

I am using VB.Net SDK of RabbitMQ.

I am setting "Durable" property of Queue Declare to true, and DeliveryMode BasicQueueProperties to "2" to make the Messages persistent. But still the messages are getting lost after my server restart.

How can I overcome this?

like image 843
madhu Avatar asked Apr 08 '15 16:04

madhu


People also ask

How do I clear my RabbitMQ queue?

A queue can be deleted from the RabbitMQ Management Interface. Enter the queue tab and go to the bottom of the page. You will find a dropdown "Delete / Purge". Press Delete to the left to delete the queue.

What happens when RabbitMQ restarts?

After the rabbitmq server or cluster is restarted, all the queue have recover all the message even the messages have be acked (from the point that rabbitmq server is started), and process all messages again.

Why are messages lost when I restart a RabbitMQ broker?

Messages, exchanges, and queues that are not durable and persistent will be lost during a broker restart. If you cannot afford to lose any messages, make sure that your queue is declared as durable and your messages are sent with delivery mode "persistent".

Does RabbitMQ delete message after consumed?

you are telling RabbitMQ to automatically acknowledge the message when it is consumed. acknowledging a message tells RabbitMQ that it has been taken care of and RabbitMQ can delete it now.


1 Answers

https://www.rabbitmq.com/tutorials/tutorial-two-dotnet.html

In this page Message durability on RabbitMQ, it's explained good:

At this point we're sure that the task_queue queue won't be lost even if RabbitMQ restarts. Now we need to mark our messages as persistent - by setting IBasicProperties.Persistent to true.

var properties = channel.CreateBasicProperties();
properties.Persistent = true;
Note on message persistence

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. The persistence guarantees aren't strong, but it's more than enough for our simple task queue. If you need a stronger guarantee then you can use publisher confirms.

like image 70
efaruk Avatar answered Sep 18 '22 08:09

efaruk