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

Gary Tully commented on AMQ-6454:
---------------------------------

What you describe does look like the correct behaviour w.r.t the java doc. 
For reference, broker side, messages are retained in the subscription that 
matches the consumer. On close, any unacked messages are replayed back to the 
queue for delivery to another consumer.
It looks like the close needs to be deferred till the session closes in this 
client ack case. That is the behaviour in a transaction. However we would need 
a new callback on the session to track this. Not a trivial fix but doable.
For your use case, is a transacted session an option?

> 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