Multiple acknowledge for the same delivery tag
Asked Answered
E

1

7

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.

Empress answered 21/5, 2015 at 21:29 Comment(4)
@Gas amqp protocol state that A message MUST not be acknowledged more than once.. The rabbit client can had a layer on top of acknowledgement. If I remain correctly this is the behaviour of the Spring one.Misdoubt
@NicolasLabrot yes you are right, BTW I tried the java client to ACK more than one and I didn't have problems. Actually never had this situation and maybe I have been a little shallow to comment, but on my test I didn't see side effects. I provide to modify the comment. Thank you!Ebullience
@Empress I removed the first comment because it was not correct. BTW if you post some code we will try to help you.Ebullience
@Gabriele this is my code to acknowledge channelObj.basicAck(Long.parseLong(dTag), false); if I fire this twice for the same message, the Queue starts acting wired.... is there a way, where I can check, if the dtag is present, and then only I send the acknowledgement ?Fop
L
3

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.

Listless answered 17/5, 2019 at 9:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.