|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
  |
|
Queue Mannager reconnecting. |
View previous topic :: View next topic |
Author |
Message
|
omar |
Posted: Tue Oct 05, 2004 9:17 am Post subject: Queue Mannager reconnecting. |
|
|
Newbie
Joined: 03 Oct 2004 Posts: 7
|
Hi all,
How can I reconnect to a Queue Manager after a connection is lost?
What I have tried to do is to create new Object of QueueManager
Code: |
MQQueueManager qMngr = new MQQueueManager(“qMannager”);
|
But I will keep getting “MQRC_CONNECTION_BROKEN 2009” Exception when I try to get the message.
I have tried to close or disconnect QueueManager first but it stills the same.
Any help please. |
|
Back to top |
|
 |
PeterPotkay |
Posted: Tue Oct 05, 2004 9:53 am Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
If you lost your original connection because of X, and X is still a problem when you try and reconnect, you will fail again. You need to drop into a loop of attemting the reconnect over and over until it works, then open the queue again and get the message.
How many times you retry and how often is up to you. _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
omar |
Posted: Tue Oct 05, 2004 11:01 pm Post subject: |
|
|
Newbie
Joined: 03 Oct 2004 Posts: 7
|
What I have tried to do is simulate connection lost, by disconnect the physical connection with MQSeries by removing the cable, and return it back.
On removing the cable I get “MQRC_Q_MGR_NOT_AVAILABLE 9059” Exception, on returning the cable back I keep getting “MQRC_CONNECTION_BROKEN 2009”.
On each exception I try to reconnect with the following code.
Code: |
// Connect to the QueueMannger, and Create Connection handle
qMngr = new MQQueueManager(“qMannager”);
// Set the options for opening inQueue that used to read requests
int openPtions = MQC.MQOO_INPUT_AS_Q_DEF;
inQueue = qMngr.accessQueue(“inQName”, openPtions);
// Set the options for opening outQueue that used to send replies
openPtions = MQC.MQOO_OUTPUT | MQC.MQOO_INQUIRE ;
outQueue = qMngr.accessQueue(“outQName”, openPtions);
|
The exception “MQRC_CONNECTION_BROKEN 2009” I keep getting forever (forever mean to me 1 hour ), and on each exception I try to reconnect with the above code.
So is the problem with my reconnect code or there is some other way to do it.
Last edited by omar on Wed Oct 06, 2004 11:15 pm; edited 1 time in total |
|
Back to top |
|
 |
omar |
Posted: Wed Oct 06, 2004 1:39 am Post subject: |
|
|
Newbie
Joined: 03 Oct 2004 Posts: 7
|
Hi PeterPotkay,
I found what the problem, it is pure java, and had to do nothing with MQSeries.
On reconnecting I create new Queue but the class who get the messages still has the old reference so it always gets 2009 exception.
OK I feel really embarrassed,
Thank you again for your help PeterPotkay. |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed Oct 06, 2004 8:09 am Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Omar,
That doesn't sound right. I have done a lot of failover testing of Java applications both JMS and non-JMS, and your diagnoses is incorrect.
I'll assume that the MaxChannel is set to the default of 100 and you are not using KeepAlive.
Therefore, each new new MQQueueManager() causes another channel connection to be used. If your application does NOT do a disconnect then the OS (Windows, Unix, etc...) will keep the 'ESTABLISHED' session forever.
Do a
Code: |
netstat -an | grep #### |
where #### is the port number of the queue manager's listener
You will see the number of connections growing until you hit the MaxChannel value. i.e. 100. And this does sound like what is happening to you.
I have applications that reconnect without any problems. here what I suggest you do:
First I would STRONGLY suggest that you use the KeepAlive=yes queue managaer setting.
Secondly, after you catch a 2009 error, you should do something like:
Code: |
if (!qMngr.isConnect())
{
qMngr.disconnect();
doMyReconnectionLogic(); // you write this.
} |
Hope that helps.
Regards,
Roger Lacroix _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
omar |
Posted: Wed Oct 06, 2004 11:17 pm Post subject: |
|
|
Newbie
Joined: 03 Oct 2004 Posts: 7
|
Hi Roger,
and thanks for your reply, but I had found what is the problem, I posted it in the post just above you.
again thanks for the reply. |
|
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
|
|
|
|