[ https://issues.apache.org/jira/browse/ARTEMIS-4520?focusedWorklogId=893233&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-893233 ]
ASF GitHub Bot logged work on ARTEMIS-4520: ------------------------------------------- Author: ASF GitHub Bot Created on: 30/Nov/23 17:47 Start Date: 30/Nov/23 17:47 Worklog Time Spent: 10m Work Description: jbertram opened a new pull request, #4696: URL: https://github.com/apache/activemq-artemis/pull/4696 (no comment) Issue Time Tracking ------------------- Worklog Id: (was: 893233) Remaining Estimate: 0h Time Spent: 10m > 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 > Time Spent: 10m > 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)