ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Designed for deadlock?

Post new topic  Reply to topic
 Designed for deadlock? « View previous topic :: View next topic » 
Author Message
dwitherspoon
PostPosted: Mon Jan 19, 2004 7:55 am    Post subject: Designed for deadlock? Reply with quote

Acolyte

Joined: 09 Dec 2003
Posts: 59

Hi folks,

Am I on crack or something, or is the JMS receive interface designed for deadlock?

Here's my scenario I'm testing.
1. Fire up MQ
2. Fire up my app, which sets a listener.
3. A message comes in, onMessage gets called, and we stop at a breakpoint.
4. Stop mQ by running endmqm TATEST.
5. I continue on past the breakpoint, and a JMSException gets thrown and caught.
6. In my handling of the exception, I want to close down my JMS resources cleanly, so I start calling close() on the queue, connection, session, etc.
7. During the call to close the session, it does not return.

Now the JMS spec says that close() blocks until onMessage completes. So that sets me up for deadlock...I have no way to cleanly close JMS resources when an error happens! Because I'm using an async listener, there is no point where I can call close() that is outside of that listener's onMessage call.

So am I on crack...is this designed for deadlock??? Some JMSExceptions are critical enough that calling close() is moot anyway. But not all of them.
_________________
Good...Fast...Cheap. Choose any two.
Back to top
View user's profile Send private message
bower5932
PostPosted: Mon Jan 19, 2004 9:46 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

It sounds like you should be using an ExceptionListener to catch asynchronous exceptions?
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
dwitherspoon
PostPosted: Tue Jan 20, 2004 5:13 am    Post subject: Already there Reply with quote

Acolyte

Joined: 09 Dec 2003
Posts: 59

I am using an ExceptionListener as well. But this interface is for delivery of exceptions to an async listener. That is, if I have set up a MessageListener, and no messages are ready, but the MOM goes down, then there is no way to tell the listener about this event except through the ExceptionListener.

So I've got that in the solution as well.

My problem happens when the MOM barfs during onMessage processing...for example, on a commit() call. My onException doesn't get called in that case, but rather the exception is thrown during onMessage after the commit fails.

OK...so if commit fails then closing down the system nicely isn't necessary. But suppose instead that I've received a message and I start making calls to extract various message properties, and one of them fails. A JMSException gets thrown at that point, and my application might be so disturbed by this event that it wants to close all the JMS resources and exit. But since close() and stop() will block until onMessage finishes, I get myself deadlocked.

What I've done is wrap these calls in a separate thread, which is no biggie. But it just seems like JMS should be doing this for me. As a developer, I shouldn't have to build my own out-of-band threads to close things down.
_________________
Good...Fast...Cheap. Choose any two.
Back to top
View user's profile Send private message
mrlinux
PostPosted: Tue Jan 20, 2004 11:43 am    Post subject: Reply with quote

Grand Master

Joined: 14 Feb 2002
Posts: 1261
Location: Detroit,MI USA

Well if you are stopping mqseries this will cause you issues when trying to close queue connections.

4) Stop mQ by running endmqm TATEST
_________________
Jeff

IBM Certified Developer MQSeries
IBM Certified Specialist MQSeries
IBM Certified Solutions Expert MQSeries
Back to top
View user's profile Send private message Send e-mail
dwitherspoon
PostPosted: Tue Jan 20, 2004 1:10 pm    Post subject: Reply with quote

Acolyte

Joined: 09 Dec 2003
Posts: 59

That's fair. close() can throw an exception.

Yes, I'm killing off MQ to generate the condition I want to test. So yes, I wouldn't be surprised if close() were to throw an exception. But I catch those exceptions on that call, than swallow them (since I'm trying to shut down anyway).

But suppose I am making a JMS call on a received message to get a message property value and that fails. Maybe I want to shut down my JMS connections if I get such a message. Can't do it.

Or suppose that I send my application command messages. My app is listening for a TextMessage of "Shutdown". When I get that message, I want to call close() on all my JMS resources. No can do.
_________________
Good...Fast...Cheap. Choose any two.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Designed for deadlock?
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.