activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stirlingc <sc...@alarmpoint.com>
Subject When is it "safe" to close a consumer?
Date Fri, 29 Feb 2008 00:40:14 GMT

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.


Mime
View raw message