Reputation: 499
I am in charge maintaining a production software written in Golang which uses RabbitMq as its message queue.
Consider the following situation:
A number of goroutines are publishing to a queue name logs.
Another set goroutines read from the queue and write the messages to a MongoDB collection.
autoAck
, exclusive
and noWait
are all set to false and prefetch
is set to 20 with global
set to false for all
channels. All queues are durable with autoDelete
, exclusive
and noWait
all set to false.The basic assumption was that each message in the queue will be delivered to one and only one consumer, so each message would be inserted in the database exactly once.
The problem is that there are duplicate messages in the MongoDB collection.
I would like to know if it is possible that more than one consumer gets the same message causing them to insert duplicates?
Upvotes: 2
Views: 3386
Reputation: 2691
The one case I could see with your setup where a message would be processed more than once is if one of the consumers has an issue at some point. The situation would follow such a scenario:
Such cases should show some errors in your consumers logs.
Upvotes: 2