[ 
https://issues.apache.org/jira/browse/AMQ-6454?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15551904#comment-15551904
 ] 

Christopher L. Shannon commented on AMQ-6454:
---------------------------------------------

Yep, you are right about the close() call being allowed and I suppose now that 
I think about it that makes sense to be able to close a message listener or 
consumer. So based on the spec allowing the close() method to be called from 
another thread I do agree that this is in fact a valid use case.

I think the default behavior should just be message.acknowledge() will fail if 
the consumer was closed.  Then, depending on how much work it is to implement, 
a flag could also be added to allow the close to be deferred to the session 
close to change the behavior.  I'll let Gary comment on this as he has looked 
into it and knows better about the level of effort required to make these 
changes.

Whatever fix is done I can back port it to 5.14.x so that it will go into a 
5.14.2 release.

> Message is redelivered after succesfull acknowledge()
> -----------------------------------------------------
>
>                 Key: AMQ-6454
>                 URL: https://issues.apache.org/jira/browse/AMQ-6454
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.14.1
>            Reporter: Yuriy
>         Attachments: activemq-bug.zip
>
>
> JMS message is redelivered after successful call of acknowledge().
> The following methods are invoked:
> Thread1 : Message message = consumer.receive();
> Thread2 : consumer.close();
> Thread1: message.acknowledge();
> All the methods return successfully but the  message is redelivered on the 
> next receive() call. Note that consumer.close() is typically used to force  
> consumer.receive() to return. 
> According to JMS specification the scope of message acknowledge() call is 
> session (not message consumer):
> https://docs.oracle.com/javaee/7/api/javax/jms/Message.html#acknowledge--
> A simple program to reproduce the bug is attached.
> Observed behavior: 
> Message is redelivered.
> Program output:
> ============
> Message sent. Id=ID:comp-63860-1475602285903-1:1:1:1:1
> Message received. Id=ID:comp-63860-1475602285903-1:1:1:1:1. Text=Welcome!
> Message succesfully acknowledged
> Message received. Id=ID:comp-63860-1475602285903-1:1:1:1:1. Text=Welcome!
> Message succesfully acknowledged
> Expected behavior:
> Message should be delivered only once.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to