Skip to content

CLIENT_ACKNOWLEDGE with JmsTemplate - implicit message acknowledge each read [SPR-13255] #17846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jul 21, 2015 · 1 comment
Assignees
Labels
in: messaging Issues in messaging modules (jms, messaging) status: declined A suggestion or change that we don't feel we should currently apply

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jul 21, 2015

Lubos Krnac opened SPR-13255 and commented

I found this code in JmsTemplate.doReceive(Session session, MessageConsumer consumer):

         Message message = doReceive(consumer, timeout);
if (session.getTransacted()) {
     // Commit necessary - but avoid commit call within a JTA transaction.
     if (isSessionLocallyTransacted(session)) {
              // Transacted session created by this template -> commit.
              JmsUtils.commitIfNecessary(session);
     }
}
else if (isClientAcknowledge(session)) {
     // Manually acknowledge message, if any.
     if (message != null) {
              message.acknowledge();
     }
}

Why is message acknowledged straight after reception before returning to application code? That effectively means we can't use JmsTemplate with CLIENT_ACKNOWLEDGE for bulk processing of messages. Does it relates somehow to #17587?


Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Sep 7, 2015

Juergen Hoeller commented

Since we recently fine-tuned our documentation on JMS acknowledge modes (#17869), this should hopefully be clearer now: Not just in listener containers but also in JmsTemplate, CLIENT_ACKNOWLEDGE is just a mode of processing each message, essentially as an alternative to transactional acknowledgment.

Since we don't hold on to the same JMS Session there but rather re-acquire one for each message, manual acknowledgment in application code is not feasible here. For custom acknowledgment of a series of messages, you'd need to avoid JmsTemplate and perform direct invocations on an explicitly acquired JMS Session there, manually releasing it at the very end.

Juergen

@spring-projects-issues spring-projects-issues added type: bug A general bug status: declined A suggestion or change that we don't feel we should currently apply in: messaging Issues in messaging modules (jms, messaging) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues removed the type: bug A general bug label Jan 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: messaging Issues in messaging modules (jms, messaging) status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

2 participants