|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Detect qmgr state in Java program |
« View previous topic :: View next topic » |
Author |
Message
|
jkoconnell |
Posted: Sun Aug 19, 2012 9:57 am Post subject: Detect qmgr state in Java program |
|
|
Newbie
Joined: 24 Feb 2005 Posts: 8
|
Hello,
I have a Java application that connects to a QMGR in bindings mode. It then monitors a directory for files to put to queues. It can be a long time between files showing up in the directory. If I shut down the qmgr while the program is running but not processing any files, it does not detect that the qmgr is gone until the next file arrives and it tries to put the file to a queue. I tried using myQmgr.isConnected(), but it always returns true if myQmgr is a valid qmgr handle. Is there some other method I can use to detect if the qmgr is quiescing, stopping, or stopped so that I can gracefully end the Java app?
Thank you |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Aug 19, 2012 12:03 pm Post subject: Re: Detect qmgr state in Java program |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
jkoconnell wrote: |
Hello,
I have a Java application that connects to a QMGR in bindings mode. It then monitors a directory for files to put to queues. It can be a long time between files showing up in the directory. If I shut down the qmgr while the program is running but not processing any files, it does not detect that the qmgr is gone until the next file arrives and it tries to put the file to a queue. I tried using myQmgr.isConnected(), but it always returns true if myQmgr is a valid qmgr handle. Is there some other method I can use to detect if the qmgr is quiescing, stopping, or stopped so that I can gracefully end the Java app?
Thank you |
You did not specify whether your app was written in Java base or JMS (stand alone or J2EE)...
In JMS you can use the ExceptionListener on the connection.
Anyways, why not just try to close and reopen the connection when you are hitting an error? If you really want to check the status you could also send a pcf qmstatus command at regular intervals...but
BEST PRACTICE says: don't monitor but try and reconnect if receiving an error (at growing interval) and after a number of failed reconnect attempts notify and exit... ALSO code all connections with Fail If Quiescing...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
jkoconnell |
Posted: Sun Aug 19, 2012 12:21 pm Post subject: |
|
|
Newbie
Joined: 24 Feb 2005 Posts: 8
|
Thanks. App is Java base. If there are no files to put, it can be a long time before a PUT is attempted. So, the program loops waiting for files to PUT, but didn't detect a QMGR shutdown until the next PUT is attempted. I solved this by periodically doing a new connect to the qmgr and checking for exceptions. The program now shuts down as soon ad the endmqm is executed.
qMyQmgr = new MQQueueManager(sMyQmgr);
..
if (mqe.reasonCode == CMQC.MQRC_Q_MGR_STOPPING) {
..
if (mqe.reasonCode == CMQC.MQRC_Q_MGR_QUIESCING) {
..
if (mqe.reasonCode == CMQC.MQRC_ALREADY_CONNECTED) { |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|