[ 
https://issues.apache.org/jira/browse/ARTEMIS-4520?focusedWorklogId=893236&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-893236
 ]

ASF GitHub Bot logged work on ARTEMIS-4520:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 30/Nov/23 18:10
            Start Date: 30/Nov/23 18:10
    Worklog Time Spent: 10m 
      Work Description: tabish121 commented on PR #4696:
URL: 
https://github.com/apache/activemq-artemis/pull/4696#issuecomment-1834302139

   This looks good assuming all the current tests still pass 




Issue Time Tracking
-------------------

    Worklog Id:     (was: 893236)
    Time Spent: 20m  (was: 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: 20m
>  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)

Reply via email to