[jboss-user] [JBoss Messaging] - Closing Consumer Causes Hang
toddjtidwell
do-not-reply at jboss.com
Fri Sep 8 15:57:13 EDT 2006
So I've run into an odd problem the last couple of days. I've been through my code and I've re-installed JBoss and Messaging several times to try and eliminate it. I can't find a solid cause.
Here's what's happening: We have a non-durable consumer that is listening to a topic. When it receives a messages with a specific int property, it knows it's supposed to stop listening and shut itself down.
It establishes it's connections at follows:
| InitialContext initialContext=new InitialContext();
|
| ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("XAConnectionFactory");
|
| Connection connection=connectionFactory.createConnection();
|
| Session session=connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
|
| Destination destination=(Destination) initialContext.lookup("OurTopic");
|
| Consumer consumer=consumer=session.createConsumer(destination, "selectorProp = 1");
|
| consumer.setMessageListener(this);
|
| connection.start();
|
Then for the onMessage method we have
| public void onMessage(Message message)
| {
| try
| {
|
| message.acknowledge();
|
| Integer closeProp=message.getIntProperty("closeProp");
|
| if (closeProp == -1)
| {
| try { connection.stop(); } catch (Exception e) {}
| try { consumer.close(); } catch (Exception e) {}
| try { session.close(); } catch (Exception e) {}
| try { connection.close(); } catch (Exception e) {}
| }
| }
| catch (JMSException e)
| {
| e.printStackTrace(System.err);
| }
| }
|
Now, here's the odd thing: It just hangs on the consumer.close() (in bold) call. This used to work. I'm not sure what's changed, I've gone back over it 50 times now and can't find anyhting I changed that would have broken it.
I've found that if I close everything from outside the onMessage method from another thread (like a timer thread or something that just watches the state of the consumer) it works fine. It's just when I close it all down in onMessage.
Is this frowned upon or should this work? Any thoughts on what might be causing it to lock?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970442#3970442
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970442
More information about the jboss-user
mailing list