On my below code connect() method is able to catch the 2009 and 2059 exceptions. But when I make my queue manager or connection down to generate 2009 or 2059 MQ exception in getMessage() method , program is getting hung or it didn't throws it .
It is waiting in line queue.get(retrievedMessage, getOptions);.
Do we need to add additional open option to make the code aware if a connection or queue manager is broken ?
Connect()
{
MQEnvironment.hostname = hostName;
MQEnvironment.channel = channelName;
MQEnvironment.port = portName;
try
{
qMgr = new MQQueueManager(EvtqManager); // define a queue manager object
LOGGER.debug("Queue Manager " +EvtqManager+ " Instance Initialized");
int openOptions = MQC.MQOO_INQUIRE + MQC.MQOO_FAIL_IF_QUIESCING+ MQC.MQOO_INPUT_SHARED;
queue = qMgr.accessQueue(queueName, openOptions, null,null,null);
LOGGER.debug("IBM MQQueue:"+queueName+" is accessed");
getOptions = new MQGetMessageOptions();
getOptions.options = MQC.MQGMO_NO_WAIT;
getMessage();
}
catch(){
if(MQex.reasonCode==2009 || MQex.reasonCode==2059){
shutDown();
Connect();
}
}
getMessage(){
MQMessage retrievedMessage;
while (true) {
try {
retrievedMessage = new MQMessage();
queue.get(retrievedMessage, getOptions);
PCFMessage pcfMessage = new PCFMessage(retrievedMessage);
}
catch (MQException MQex) {
if(MQex.reasonCode==2009 || MQex.reasonCode==2059){
shutDown();
Connect();
}
}
}
`