You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by Justin Bertram <jb...@apache.org> on 2023/12/01 17:31:02 UTC
Re: JMS API with client acknowledgement issue
FYI - the fix for this issue has been merged. It will be available in
ActiveMQ Artemis 2.32.0.
Thanks again for the report!
Justin
On Thu, Nov 30, 2023 at 11:46 AM Justin Bertram <jb...@apache.org> wrote:
> 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 Андрей <x0...@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
>>
>