Author |
Message
|
girish_a |
Posted: Tue Jan 18, 2011 8:55 pm Post subject: Java: Want to monitor or ping to check if MQ connection live |
|
|
Newbie
Joined: 18 Jan 2011 Posts: 2
|
Hi
I want to check programatically every few seconds or have a listner which is notified when the connection to MQSeries queue is lost.
I tried using isConnected() and isOpen() APIs from MQManager, but they seem to be giving data from cache which is giving status as connected though the connection is lost.
I want to monitor connection and immediately when a connection is lost, want to retry to connect again.
Is there any API which will help me implement this? |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Jan 18, 2011 9:02 pm Post subject: Re: Java: Want to monitor or ping to check if MQ connection |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
girish_a wrote: |
Hi
I want to check programatically every few seconds or have a listner which is notified when the connection to MQSeries queue is lost.
I tried using isConnected() and isOpen() APIs from MQManager, but they seem to be giving data from cache which is giving status as connected though the connection is lost.
I want to monitor connection and immediately when a connection is lost, want to retry to connect again.
Is there any API which will help me implement this? |
Have you looked at the ExceptionListener. You put it on the connection.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
girish_a |
Posted: Wed Jan 19, 2011 1:07 am Post subject: We are not using JMS, using MQ API directly |
|
|
Newbie
Joined: 18 Jan 2011 Posts: 2
|
Hi
Thanks for the quick reply.
I am not using JMS to connect to MQ. I use the MQ API, like MQQueueManager, MQQueue.
Could you suggest if I there is any way to handle such connection lost exceptions?
Thanks in Advance |
|
Back to top |
|
 |
gbaddeley |
Posted: Wed Jan 19, 2011 4:35 pm Post subject: Re: Java: Want to monitor or ping to check if MQ connection |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
girish_a wrote: |
I want to check programatically every few seconds ..... when the connection to MQSeries queue is lost. |
This is generally a bad idea in any MQ programming environment. If loss of connection is a concern for the program (eg. its a MQ Client), you should detect it on return from all calls to MQ, and handle appropriately. This may include backing out, retry or recovery of transactions.
Unexpected disconnection can happen at any time (eg. 2009 reason code), even after you have just detected a disconnection and then reconnected. So it can still occur on any open / get / put etc.  _________________ Glenn |
|
Back to top |
|
 |
Vitor |
Posted: Wed Jan 19, 2011 5:32 pm Post subject: Re: Java: Want to monitor or ping to check if MQ connection |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
girish_a wrote: |
I want to monitor connection and immediately when a connection is lost, want to retry to connect again. |
Why not simply react to the reason code when you get it? Just because you tested a connection a few seconds ago doesn't mean it's working when you use it a few seconds later.
Or use WMQv7's inbuild client auto-reconnect. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|