Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple acknowledge for the same delivery tag

In my project I saw that there is a chance of acknowledging the same delivery tag twice. When this happens, the consumer gets unbound from the queue and no further messages come to the consumer (Observed using the RabbitMQ management dashboard).

How can I check that a given delivery tag has already been acknowledged? Is there a recommended way to handle such scenario using the RabbitMQ API?

I tried to avoid acknowledging twice in my code but unfortunately it is not possible due to some design issues.

like image 239
syodage Avatar asked May 21 '15 21:05

syodage


People also ask

How do you consume multiple messages in RabbitMQ?

To increase the performance and to consume more messages at a time, do as follows: Open the "RabbitMQ connection" and go to the Event sources tab. In Advanced Settings > "Other Attributes:", add “concurrentConsumers” property. For instance: concurrentConsumers=10.

What is RabbitMQ delivery tag?

Delivery Identifiers: Delivery Tags When a consumer (subscription) is registered, messages will be delivered (pushed) by RabbitMQ using the basic. deliver method. The method carries a delivery tag, which uniquely identifies the delivery on a channel. Delivery tags are therefore scoped per channel.

Can RabbitMQ have multiple consumers?

No it's not, single queue/multiple consumers with each consumer handling the same message ID isn't possible. Having the exchange route the message onto into two separate queues is indeed better.

What does ack mean in RabbitMQ?

Acknowledgements (Consumer Acknowledgements, Ack, Delivery Acknowledgements) When RabbitMQ delivers a message to a consumer, it needs to know when to consider the message successfully sent. An ack will acknowledge one or more messages, which tells RabbitMQ that a message/messages has been handled.


1 Answers

As the AMQP protocol reference is pretty clear about this:

A message MUST not be acknowledged more than once. The receiving peer MUST validate that a non-zero delivery-tag refers to a delivered message, and raise a channel exception if this is not the case. ...

A quick test reveals that, at least in current versions, this does not cause a consumer to stop working, but that behavior might be implementation-dependent.

In short, you would have to review your design to avoid this situation.

like image 53
istepaniuk Avatar answered Sep 28 '22 12:09

istepaniuk