You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by stirlingc <sc...@alarmpoint.com> on 2008/02/29 01:40:14 UTC

When is it "safe" to close a consumer?

Hello,

I have a test case that's currently failing with ActiveMQ 5.0.0 and
5.1-SNAPSHOT, and I want to confirm the proper behaviour before I file a
JIRA ticket.  My test involves creating a queue that contains a single
queue.  Two consumers within separate sessions attempt to read from the
queue synchronously.  The first consumer gets the message, but rolls back
the session/transaction.  The second consumer gets the redelivered message
and commits the session/transaction.

All works fine when the first consumer is closed after the session is rolled
back:

session.rollback();
consumer.close();
session.close();
conn.close();

However, when I change the code so that the consumer is closed before the
rollback, the second consumer hangs in its receive() call, never having
received the message.  However, the message appears to remain in the queue:

consumer.close();
session.rollback();
session.close();
conn.close();

-----
The hello-world example included with ActiveMQ shows the consumer being
closed before the session is closed.  Since an uncommitted session should be
implicitly rolled back when the session is closed, I don't think that it
should be wrong to explicitly close a consumer before session rollback.

Can someone please confirm that the ordering should be irrelevant?  If so,
I'll go ahead and submit the Junit test with a bug report.
-- 
View this message in context: http://www.nabble.com/When-is-it-%22safe%22-to-close-a-consumer--tp15749587s2354p15749587.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: When is it "safe" to close a consumer?

Posted by stirlingc <sc...@alarmpoint.com>.
My original message has a typo.  The test involves create a single queue with
a single *message*.
-- 
View this message in context: http://www.nabble.com/When-is-it-%22safe%22-to-close-a-consumer--tp15749587s2354p15749606.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.