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 » Detect qmgr state in Java program

Post new topic  Reply to topic
 Detect qmgr state in Java program « View previous topic :: View next topic » 
Author Message
jkoconnell
PostPosted: Sun Aug 19, 2012 9:57 am    Post subject: Detect qmgr state in Java program Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Sun Aug 19, 2012 12:03 pm    Post subject: Re: Detect qmgr state in Java program Reply with quote

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
View user's profile Send private message Send e-mail
jkoconnell
PostPosted: Sun Aug 19, 2012 12:21 pm    Post subject: Reply with quote

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
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 » Detect qmgr state in Java program
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.