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 » Question on onMessage()

Post new topic  Reply to topic
 Question on onMessage() « View previous topic :: View next topic » 
Author Message
rsinha
PostPosted: Thu Mar 30, 2006 12:05 am    Post subject: Question on onMessage() Reply with quote

Apprentice

Joined: 29 Aug 2003
Posts: 42

Have seen a few posts on this subject but haven't yet found what I'm looking for. My JMS app is using non-transacted auto-acknowledge session at the moment (can switch to client-acknowledge, if that will deliver the functionality I'm aiming for). In the onMessage() method of the receiver, we are procesing the received msg and then try to persist it. Recently, the persisiting started failing because of some system failures (since the, we've taken steps to cut down those system failures). Anyway, as a result, the msgs were retrieved from the Q and couldn't be persisted, hence we lost those msgs.
So, is there a way, in onMessage(), that if for some reason whatever processing its trying to do on the msg (in this case persisting it), if fails, we stop the delivery of messages from the queue, by may be stopping the connection?
Then, after fixing the problem that was causing the system failure, we can somehow indicate to the application to restart the connection on that listener, and hope to retrieve the last message, that the processing in onMessage failed on, so not to lose any transactions.
Back to top
View user's profile Send private message
briancop
PostPosted: Thu Mar 30, 2006 12:10 am    Post subject: Reply with quote

Apprentice

Joined: 04 Apr 2005
Posts: 28
Location: Hursley, UK

I think you have a couple of choices:
Use a transacted session (this just means that the MQ/JMS work is transacted, not that you have 2-phase commit distributed transactions). If you get a message into onMessage and successfully handle it, commit the session; if anything goes wrong fix the problem and rollback the session.

Or use client acknowledgement. If you handle the message successfully, acknowledge the message at the end of your onMessage callback; if anything goes wrong fix the problem and call session.recover() to redeliver any unacknowledged messages.

Brian
Back to top
View user's profile Send private message
rsinha
PostPosted: Thu Mar 30, 2006 8:06 am    Post subject: Reply with quote

Apprentice

Joined: 29 Aug 2003
Posts: 42

Thanx for the suggestions, I'm leaning towards CL_ACK. A few questions, since in onMessage() I don't have access to session object, I'll not be able to call session.recover() from there. Also, from onMessage() I'm not supposed to throw any exceptions, so I guess I can set a property in onMessage() , which the main program would look for, to do session.recover().
Now, say my first msg retrieved fails to persist, and I don't acknoledge it in onMessage(), in my main program before I do session.recover() (because i can do that only after fixing the system resource problem and that take a while), it'd keep on deliverying the subsequent msgs to onMessage() , which will all keep on erroring out?
Back to top
View user's profile Send private message
briancop
PostPosted: Thu Mar 30, 2006 8:22 am    Post subject: Reply with quote

Apprentice

Joined: 04 Apr 2005
Posts: 28
Location: Hursley, UK

Sending some kind of property/semaphore to the main thread to notify it of a problem should be ok. Alternatively, can you store a reference to the session in whatever object you have used to implement the MessagListener interface, so that onMessage has access to it?

If you go for the option of resolving the problem using the main thread, you are right; the message delivery might continue and you'll keep getting failures. One possibility would be temporarily stop the connection while you sort the problem, then session.recover() then connection.start(). This will prevent any further message delivery until you restart the connection.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Mar 30, 2006 1:49 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

rsinha wrote:
Thanx for the suggestions, I'm leaning towards CL_ACK. A few questions, since in onMessage() I don't have access to session object, I'll not be able to call session.recover() from there. Also, from onMessage() I'm not supposed to throw any exceptions, so I guess I can set a property in onMessage() , which the main program would look for, to do session.recover().
Now, say my first msg retrieved fails to persist, and I don't acknoledge it in onMessage(), in my main program before I do session.recover() (because i can do that only after fixing the system resource problem and that take a while), it'd keep on deliverying the subsequent msgs to onMessage() , which will all keep on erroring out?


Who said you could not throw any exceptions?
Have you tried throwing a JMSException ?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Question on onMessage()
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.