Why are JMS messages acknowledged after onMessage()
listener method returns even if acknowledgment mode is set to CLIENT_ACKNOWLEDGE
?
If you look at the commitIfNecessary
method in the AbstractMessageListenerContainer
class, you can see the following:
protected void commitIfNecessary(Session session, Message message) throws JMSException {
// Commit session or acknowledge message.
if (session.getTransacted()) {
// Commit necessary - but avoid commit call within a JTA transaction.
if (isSessionLocallyTransacted(session)) {
// Transacted session created by this container -> commit.
JmsUtils.commitIfNecessary(session);
}
} else if (message != null && isClientAcknowledge(session)) {
message.acknowledge();
}
}
After debugging, I confirm that message.acknowledge()
is called.
I thought that CLIENT_ACKNOWLEDGE
means I need to acknowledge message manually?
Any idea?
Thanks, Mickael