manual message acknowledgement is broken in 2.x with a MessageListener and requeueOnMessageListenerException=true #582
lepurvis-fadv
started this conversation in
General
Replies: 1 comment 2 replies
-
@lepurvis-fadv please put together an executable example we can use to reproduce. Server logs and/or a traffic capture would also help. "It should work" is not a behavior we can reason about but an executable example usually clarifies a lot. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
Calling
Message.acknowledge()
from insideMessageListener.onMessage()
is basically a no-op ifRMQConnectionFactory.setRequeueOnMessageListenerException(true)
and theRMQSession
is created withCLIENT_INDIVIDUAL_ACKNOWLEDGE
orCLIENT_ACKNOWLEDGE
- the acknowledgement is never sent to the rabbitmq server.In
com.rabbitmq.jms.client.RMQSession.acknowledge(long)
line 1336unackedMessageTags
is always empty.This is due to
com.rabbitmq.jms.client.MessageListenerConsumer.handleDelivery(String, Envelope, BasicProperties, byte[])
not callingdealWithAcknowledgments()
before calling theMessageListener
whenthis.requeueOnMessageListenerException
is true.dealWithAcknowledgments()
in turn calls back to the session, which is what populatesunackedMessageTags
.The fix is more involved than just reordering
dealWithAcknowledgments()
as is done whenthis.requeueOnMessageListenerException
is false, as when it is true, it shouldn't be called if the message needs to be nacked.So somehow
com.rabbitmq.jms.client.RMQSession.unackedMessageTags
needs to be populated before dispatching a message to aMessageListener
.Reproduction steps
...
Expected behavior
javax.jms.Message.acknowledge() should acknowledge the message as defined by the JMS spec, i.e. the rabbitmq server should receive an ack for the message.
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions