[
https://issues.apache.org/jira/browse/ARTEMIS-4520?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Justin Bertram resolved ARTEMIS-4520.
-------------------------------------
Fix Version/s: 2.32.0
Resolution: Fixed
> JMSContext.acknowledge() doesn't work if last message received is null
> ----------------------------------------------------------------------
>
> Key: ARTEMIS-4520
> URL: https://issues.apache.org/jira/browse/ARTEMIS-4520
> Project: ActiveMQ Artemis
> Issue Type: Bug
> Reporter: Justin Bertram
> Assignee: Justin Bertram
> Priority: Major
> Fix For: 2.32.0
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
> I've stumbled into an issue with client acknowledge mode when using the JMS
> API. Here's an example:
> {code:java}
> try (var factory = new ActiveMQConnectionFactory("<broker-url")) {
> try (var ctx = factory.createContext("<user>", "<password>",
> JMSContext.CLIENT_ACKNOWLEDGE)) {
> var destination = ctx.createQueue("<destination>");
> try (var consumer = ctx.createConsumer(destination)) {
> var message1 = consumer.receive(100000); // suppose this
> call returns real message
> var message2 = consumer.receive(100000); // suppose this
> call times out, so NULL is returned
> ctx.acknowledge(); // I'm expecting that message1 gets
> acknowledged here, but it's not happening
> /*
> Do something here...
> */
> }
> }
> }{code}
> The reason for ack not working is that the implementation of
> {{JMSConsumer.receive}} stores the latest returned value in
> {{org.apache.activemq.artemis.jms.client.ActiveMQJMSContext}} for future
> usage in its {{acknowledge}} implementation. This happens regardless if the
> value is {{null}} or not. So in case the latest call to receive a message
> returns {{null}} then calling {{JMSContext.acknowledge()}} does nothing.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)