|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Modifying existing client for multi-instance using SVRCONN |
« View previous topic :: View next topic » |
Author |
Message
|
Gideon |
Posted: Fri Aug 23, 2013 12:55 pm Post subject: Modifying existing client for multi-instance using SVRCONN |
|
|
Chevalier
Joined: 18 Aug 2009 Posts: 403
|
I was given Java code using SVRCONN to send messages, below is a portion:
Code: |
private static String host = "10.14.101.191";
private static int port = 1414;
private static String channel = "SYSTEM.ADMIN.SVRCONN";
private static String qmgr = "WQM";
private static String qName = "TEST";
....
cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, host);
cf.setIntProperty(WMQConstants.WMQ_PORT, port);
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, channel);
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, qmgr); |
For various reasons, I need to continue use of the SVRCONN channel.
All of the documentation I have seen refers to the CONNAME attribute, as follows
Code: |
CONNAME('host(port),host(port)') |
However, CONNAME is not an attribute of SVRCONN
Since SVRCONN are 1 socket connections directly assigned to the server, and I can see no examples of how to do this, the only solution I can think of is to connect to the channel, but trap for a JMS exception, something like:
Code: |
private static String host = "10.14.101.191";
private static String standbyhost = "10.14.101.192";
...
catch (JMSException jmsex) {
System.out.println("-- Switching to standby instance on another IP");
cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, standbyhost);
connection = cf.createConnection();
session = connection.createSession(txEnabled ? true : false, Session.AUTO_ACKNOWLEDGE);
queue = session.createQueue(qName);
producer = session.createProducer(queue);
producer.setDeliveryMode(DeliveryMode.PERSISTENT);
connection.start();
break;
} |
and then reconnect using the other standbyhost IP.
The MQ Explorer must have a solution to this, since they collect two different IP's for a single SVRCONN.
I find my potential solution clunky, what would be the recommended approach to using SVRCONN in a java client when writing for potential failover? |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Aug 24, 2013 6:47 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You need to use the connectionNameList property of the cf. (value= ('host(port),host(port)')
Have fun  _________________ MQ & Broker admin |
|
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
|
|
|
|