I've created ARTEMIS-4520 [1] to deal with this. Thanks for reporting the issue!
Justin [1] https://issues.apache.org/jira/browse/ARTEMIS-4520 On Wed, Nov 29, 2023 at 4:08 AM Андрей <x05...@gmail.com> wrote: > Hi Team, > > I am currently using "artemis-jakarta-client" 2.31.2 version > > I've stumbled into an issue with client acknowledge mode when using JMS > API. Here's an example: > > > 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.... > */ > > } > } > } > > The reason for ack not working is that the implementation of > "consumer.receive" method stores the latest returned value in JMSContext > for future usage in its "acknowledge" method. > This happens regardless if the value is null or not. So in case latest call > returns null, all the previous messages get lost and never acked. > > This seem like a defect. Am I right? > > Thanks in advance >