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 » General Discussion » MQ JMS setClientReconnectOptions doesn't work as expected?

Post new topic  Reply to topic
 MQ JMS setClientReconnectOptions doesn't work as expected? « View previous topic :: View next topic » 
Author Message
pinghuican
PostPosted: Sat Jan 19, 2013 5:23 pm    Post subject: MQ JMS setClientReconnectOptions doesn't work as expected? Reply with quote

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
View user's profile Send private message
pinghuican
PostPosted: Sat Jan 19, 2013 9:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
exerk
PostPosted: Sun Jan 20, 2013 3:49 am    Post subject: Re: MQ JMS setClientReconnectOptions doesn't work as expecte Reply with quote

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
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 » General Discussion » MQ JMS setClientReconnectOptions doesn't work as expected?
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.