|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
MQ JMS setClientReconnectOptions doesn't work as expected? |
« View previous topic :: View next topic » |
Author |
Message
|
pinghuican |
Posted: Sat Jan 19, 2013 5:23 pm Post subject: MQ JMS setClientReconnectOptions doesn't work as expected? |
|
|
Newbie
Joined: 19 Jan 2013 Posts: 2
|
I have a simple code to put 2 messages into a queue.
1) I set the connectionNameList with two servers.
2) Those two servers are independent, but have the same Queue Manager and Queue defined with same name, such as "QMgr" and "TEST.IN"
3) I set the setClientReconnectOptions(WMQConstants.WMQ_CLIENT_RECONNECT);
I hope when the first server is down, it should send the messages to 2nd one.
The test I did:
a) I send first message, sender.send(message); It worked.
b) sleep 30 seconds.
During this time, I shutdown the first server
c) then sleep done, try to send 2nd message, but it failed to send immediately
Further more, I tried more, I did try{} catch{} for 2nd message, and in the catch{}, I try to sender.send(message), it still fails.
Any idea why it is different than what I expected. I will really appreciate your reply.
Code: |
public static void main(String[] args) throws Exception
{
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
cf.setConnectionNameList("10.230.34.191(1418),10.230.34.169(1418)");
cf.setQueueManager("QMgr");
cf.setTransportType(WMQConstants.WMQ_CM_CLIENT);
cf.setClientReconnectOptions(WMQConstants.WMQ_CLIENT_RECONNECT);
cf.setClientReconnectTimeout(600);
System.out.println("connect list " + cf.getConnectionNameList());
MQQueueConnection connection = (MQQueueConnection) cf
.createQueueConnection("mqm", "passwd");
MQQueueSession session = (MQQueueSession) connection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
MQQueue queue = (MQQueue) session.createQueue("queue:///TEST.IN");
MQQueueSender sender = (MQQueueSender) session.createSender(queue);
long uniqueNumber = System.currentTimeMillis() % 1000;
JMSTextMessage message = (JMSTextMessage) session.createTextMessage("SimplePTP "
+ uniqueNumber);
// Start the connection
connection.start();
sender.send(message);
System.out.println("Sent message:\\n" + message);
System.out.println("sleep 30 seconds");
Thread.sleep(30000);
uniqueNumber = System.currentTimeMillis() % 1000;
message = (JMSTextMessage) session.createTextMessage("SimplePTP " + uniqueNumber);
sender.send(message); // this 2nd message failed in my scenario :(
sender.close();
session.close();
connection.close();
System.out.println("\\nSUCCESS\\n");
}
|
 |
|
Back to top |
|
 |
pinghuican |
Posted: Sat Jan 19, 2013 9:08 pm Post subject: |
|
|
Newbie
Joined: 19 Jan 2013 Posts: 2
|
I think I found why.
The way I shutdown the MQ Manager, e.g, Controlled Shutdown, is one of cases that MQ failover not supported.
• Only explicit ends or failures
–Communications failure
–Queue manager or listener failure
–STOP CONN
–endmqm –s or endmqm –r
• The following will not cause reconnect
–STOP CHANNEL
–Any other endmqm |
|
Back to top |
|
 |
exerk |
Posted: Sun Jan 20, 2013 3:49 am Post subject: Re: MQ JMS setClientReconnectOptions doesn't work as expecte |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
pinghuican wrote: |
2) Those two servers are independent, but have the same Queue Manager and Queue defined with same name, such as "QMgr" and "TEST.IN" |
The above suggests that you have two independent queue managers of the same name on two separated and discrete systems...
pinghuican wrote: |
The way I shutdown the MQ Manager, e.g, Controlled Shutdown, is one of cases that MQ failover not supported. |
...but the above suggests the queue manager is Multi-Instance, which is a High-Availability solution and therefore the same queue manager.
It would be easier for all if you more accurately describe your topology, which will lead to better targeted advice. _________________ It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys. |
|
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
|
|
|
|