You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Gary Tully <ga...@gmail.com> on 2010/05/07 17:57:24 UTC

Re: ActiveMQ problem with closing a connection that has a MessageListener attached

can you raise a jira issue with your code as a junit test case? that does
seem odd.

On 7 May 2010 16:29, jid1jid1 <ji...@dharma.gr> wrote:

>
> Hi,
>
> I have the following setup:
> JMSClient - ActiveMQ 5.3.1
> JMSServer - ActiveMQ 5.3.0
>
> I create a QueueConnection-> QueueSession -> MessageConsumer
> I set my messageListener on the MessageConsumer and use conn.start() to
> flush
>
> If my queue has messages, When I try to remove the messageListener or even
> just CLOSE the connection, I get a deadlock.
>
> If the queue is empty, everything works as expected.
>
> Seems like a bug to me. Has anyone experienced this before?
>
> Many thanks
> --
> View this message in context:
> http://old.nabble.com/ActiveMQ-problem-with-closing-a-connection-that-has-a-MessageListener-attached-tp28487625p28487625.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
http://blog.garytully.com

Open Source Integration
http://fusesource.com

Re: ActiveMQ problem with closing a connection that has a MessageListener attached

Posted by Bruce Snyder <br...@gmail.com>.
On Mon, May 10, 2010 at 3:53 AM, jid1jid1 <ji...@dharma.gr> wrote:
>
> Apologies for not raising an issue with jira (need time to login and as
> always running for deadlines. I have attached a draft Unit test that
> basically shows that a deadlock will occur if one message listener does not
> return (ie. a MessageListener will not get interupted when we ask for a
> session to close). Not sure if this is supposed to be like that on not by
> JMS Spec. (If I have some time later, I will properly update this issue)

In the JMS spec, section 4.4.14 Serial Execution of Client Code it states:

'To receive messages asynchronously, a client registers an object that
implements the JMS MessageListener interface with a MessageConsumer.
In effect, a Session uses a single thread to run all its
MessageListeners. While the thread is busy executing one listener, all
other messages to be asynchronously delivered to the session must
wait.'

So this places a requirement on the MessageListener that it be
thread-safe. This requirement from the JMS spec is similar to the
requirement for servlets from the servlet spec that says a servlet
must be thread-safe. It's the job of the developer to implement a
thread-safe client that does not misbehave. Locking indefinitely would
be an example of misbehavior. There is nothing in the JMS spec stating
that the Session should make up for such bad behavior, but there is no
reason that a misbehaving MessageListener couldn't be forcibly closed
if it is causing the execution to hang (e.g., perhaps beyond a given
timeout period).

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

ActiveMQ in Action: http://bit.ly/2je6cQ
Blog: http://bruceblog.org/
Twitter: http://twitter.com/brucesnyder

Re: ActiveMQ problem with closing a connection that has a MessageListener attached

Posted by jid1jid1 <ji...@dharma.gr>.
Apologies for not raising an issue with jira (need time to login and as
always running for deadlines. I have attached a draft Unit test that
basically shows that a deadlock will occur if one message listener does not
return (ie. a MessageListener will not get interupted when we ask for a
session to close). Not sure if this is supposed to be like that on not by
JMS Spec. (If I have some time later, I will properly update this issue)
Thanks

  ( http://old.nabble.com/file/p28509588/ConnectionLockTest.java
ConnectionLockTest.java 

Gary Tully wrote:
> 
> can you raise a jira issue with your code as a junit test case? that does
> seem odd.
> 
> On 7 May 2010 16:29, jid1jid1 <ji...@dharma.gr> wrote:
> 
>>
>> Hi,
>>
>> I have the following setup:
>> JMSClient - ActiveMQ 5.3.1
>> JMSServer - ActiveMQ 5.3.0
>>
>> I create a QueueConnection-> QueueSession -> MessageConsumer
>> I set my messageListener on the MessageConsumer and use conn.start() to
>> flush
>>
>> If my queue has messages, When I try to remove the messageListener or
>> even
>> just CLOSE the connection, I get a deadlock.
>>
>> If the queue is empty, everything works as expected.
>>
>> Seems like a bug to me. Has anyone experienced this before?
>>
>> Many thanks
>> --
>> View this message in context:
>> http://old.nabble.com/ActiveMQ-problem-with-closing-a-connection-that-has-a-MessageListener-attached-tp28487625p28487625.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> http://blog.garytully.com
> 
> Open Source Integration
> http://fusesource.com
> 
> 

-- 
View this message in context: http://old.nabble.com/ActiveMQ-problem-with-closing-a-connection-that-has-a-MessageListener-attached-tp28487625p28509588.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.