[jira] [Commented] (AMQ-6454) Message is redelivered after succesfull acknowledge()

2016-10-07 Thread Gary Tully (JIRA)

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

Gary Tully commented on AMQ-6454:
-

yes, that would be in the intent. When the broker url is: host:port?jms 
ignoreConsumerCloseOnClientAck=true 
the close would be ignored, session close will call close on all consumers. 
Then the close check in the message.acknowledge would pass and the ack would 
work.

> 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)


[jira] [Commented] (AMQ-6454) Message is redelivered after succesfull acknowledge()

2016-10-07 Thread Yuriy (JIRA)

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

Yuriy commented on AMQ-6454:


Gary, will it be possible to specify this configuration option in 
"java.naming.provider.url" like "tcp://localhost:61616?option=value" when 
instantiation of JNDI initial context and connection factory is done in JMS 
provider independent way?

Will enabling of this option (deferred close) make consumer.receive() to return 
after consumer.close()?

> 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)


[jira] [Commented] (AMQ-6454) Message is redelivered after succesfull acknowledge()

2016-10-07 Thread Gary Tully (JIRA)

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

Gary Tully commented on AMQ-6454:
-

What would be a good name for the connection factory config option that ignores 
consumer.close for client or invdvidual ack mode such that session close is 
required to release the consumer and unacked messages? 

Here is one candidate:
 - ignoreConsumerCloseOnClientAck=true

I think it would default to false to preserve typical usage.

> 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)


[jira] [Commented] (AMQ-6454) Message is redelivered after succesfull acknowledge()

2016-10-07 Thread ASF subversion and git services (JIRA)

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

ASF subversion and git services commented on AMQ-6454:
--

Commit e91f5c8062f81a76e6983c489bfd092ce4071480 in activemq's branch 
refs/heads/master from [~gtully]
[ https://git-wip-us.apache.org/repos/asf?p=activemq.git;h=e91f5c8 ]

AMQ-6454 - ensure message.acknowledge throws if consumer has closed and message 
has been released broker side


> 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)


[jira] [Commented] (AMQ-6454) Message is redelivered after succesfull acknowledge()

2016-10-06 Thread Christopher L. Shannon (JIRA)

[ 
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)


[jira] [Commented] (AMQ-6454) Message is redelivered after succesfull acknowledge()

2016-10-06 Thread Yuriy (JIRA)

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

Yuriy commented on AMQ-6454:


Gary, I think having message.acknowledge() fail if a consumer was already 
closed can be considered as workaround, which prevents unexpected redelivery 
(in other words duplication of messages).

But this type of fix will not make behavior compliant to JMS specification.
You are right: JMS session should not be shared across threads.
But JMS specification explicitly states that method close() is the only method 
of message consumer and session, which can be called concurrently:
https://docs.oracle.com/javaee/7/api/javax/jms/MessageConsumer.html#close--
https://docs.oracle.com/javaee/7/api/javax/jms/Session.html#close--
That's why consumer.close() is frequently used from another thread to make 
consumer.receive() return. 

In the described use case both receive() and acknowledge() methods are invoked 
from the same thread. Method close() is invoked from another thread.
Therefore it is absolutely valid use case.

Thread1 : Message message = consumer.receive();
Thread2 : consumer.close();
Thread1: message.acknowledge();

I think that till the next major release of ActiveMQ some configuration option 
that will allow to switch to legacy behavior (or otherwise to the new behavior) 
would be acceptable solution for all ActiveMQ users.

> 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)


[jira] [Commented] (AMQ-6454) Message is redelivered after succesfull acknowledge()

2016-10-06 Thread Christopher L. Shannon (JIRA)

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

Christopher L. Shannon commented on AMQ-6454:
-

[~gtully], I've been watching this thread and my first thoughts were what you 
discovered, that things would break if this behavior changed.  I know I have 
written code that relies on this behavior (ie closing the consumer will cause 
redelivery without closing the session)

To me this use case seems a bit odd as a JMS session should not be shared 
across threads.  The spec is clear in that a session should be single threaded. 
 So having two different threads receive a message and then try to call 
acknowledge should be considered invalid anyways in my opinion based on the 
spec.

> 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)


[jira] [Commented] (AMQ-6454) Message is redelivered after succesfull acknowledge()

2016-10-06 Thread Gary Tully (JIRA)

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

Gary Tully commented on AMQ-6454:
-

This essentially comes down to being able to do the following:
{code}
consumer.close();
message.acknowledge();
{code}
Deferring the close till the session closes makes this work but there are many 
tests that demo uses cases where close is expected to release un-acked 
messages. I think we can't break this expectation so it would need to be 
configurable (yet another option).
As an alternative, we can make message.acknowledge(); fail if the consumer is 
closed. This will ensure that the is no false positive from the acknowledge 
call.
Would that be sufficient for your use case?



> 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)


[jira] [Commented] (AMQ-6454) Message is redelivered after succesfull acknowledge()

2016-10-05 Thread Gary Tully (JIRA)

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

Gary Tully commented on AMQ-6454:
-

actually the fix may be a simple as deferring the close in this case, the 
session close will cleanup in any event. Will give the unit tests a whirl to 
see if this change breaks any existing use case.

> 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)


[jira] [Commented] (AMQ-6454) Message is redelivered after succesfull acknowledge()

2016-10-05 Thread Yuriy (JIRA)

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

Yuriy commented on AMQ-6454:


Gary, thank you for the quick response.
I know that transacted session will work and it does, but in our case there is 
an explicit requirement to use a non-transacted JMS session.
By the way this sequence works for other JMS providers like IBM WebSphere MQ, 
OpenMQ and WebLogic.
Another issue here is acknowledge() returns successfully, which in general 
means that message was acknowledged on JMS server side.


> 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)


[jira] [Commented] (AMQ-6454) Message is redelivered after succesfull acknowledge()

2016-10-05 Thread Gary Tully (JIRA)

[ 
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)