[
https://issues.apache.org/jira/browse/ARTEMIS-4520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17792146#comment-17792146
]
ASF subversion and git services commented on ARTEMIS-4520:
----------------------------------------------------------
Commit c858323f07a1133c3c3590c2030da3f6ef9427c5 in activemq-artemis's branch
refs/heads/main from Justin Bertram
[ https://gitbox.apache.org/repos/asf?p=activemq-artemis.git;h=c858323f07 ]
ARTEMIS-4520 JMSContext.acknowledge() doesn't work if last message received is
null
> 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: 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)