RabbitMQ Consumer Connection Dies

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RabbitMQ Consumer Connection Dies

mohdzubairpasha
This post has NOT been accepted by the mailing list yet.
Dear All,

I have a very weird sort of requirement.

I have a producer which sends the message to the Queue and I have three consumers which fetches the messages from Queue and perform some tasks ( here doing some Database Operations) and acknowledge the Server that the message is processed.

My Case is:

Let's say i wanna insert some record in database through the client.

here let's say i wanna insert "Name" into database.

So Producer will send the "Name" as "Test from Hello World" to the Queue as a message.

This message is taken by one of the consumer and starts processing and inserts the data to database

Let's say i will send "Test01 Hello World" into the Queue as a message.

This Message("Test01 Hello World") is taken by one of the consumer and starts processing and inserts the data to database.

But when sending back the acknowledgement let's say that the consumer is died and it will not acknowledge the server about the message.

So in this case the Message is requeued and redelivered to another consumer and starts processing and saves again in the database which is "Duplication of data in my database".

How can i avoid this sort of problems about deduplication?


I have two cases:

1) If the database processing is done and the consumer is died, what should i do to avoid further duplication?
2) Before the database processing is done and the consumer is died, how to tell rabbitmq server to requeue it and redeliver to another consumer?


Please answer me


Loading...