An interesting discussion on the use of client connection wildcards came up on mqseries.net today. This is documented in the Application Programming Reference and Clients manuals, but I’ve not seen it used very often and it can help to see how it works with a practical example.
In this post, I’ll go through an example of why you might want to use a wildcard in an MQCONN call and show the effect that it has.
Background
Imagine you had two queue managers called DALE in your network, one on a machine with IP address 9.9.9.9 and one on a machine with the IP address 8.8.8.8. And you want to define the connection from your client to queue managers with a Client channel definition table.
The obvious channel definitions to make in the channel table might be:
1 : define channel(IN.SVRCONN.x) chltype(CLNTCONN) conname(9.9.9.9) qmname(DALE)
2 : define channel(IN.SVRCONN.y) chltype(CLNTCONN) conname(8.8.8.
qmname(DALE)
In your client application, if you tried MQCONN to DALE this would pick up the first definition which matches the QMNAME parameter (e.g. - 1), and try to connect to it. On successful connection, it will negotiate, and part of this is to get the queue manager name of the remote end (in this case “DALE”). If this doesnt match the name in the MQCONN, then the connection fails.
If the connection fails for any reason (e.g. the first destination is unavailable, invalid queue manager name at the remote end etc.) then we retry the MQCONN with the next matching definition (e.g. - 2). This ability provides a very basic level of failover when a node is unavailable.
This does mean that there is no way to select which “DALE” you want to connect to when using client channel definition tables. (One way to programatically choose one would be to code the whole channel definition yourself rather than relying on a lookup in a definition table). This is one of a number of reasons why it is not generally recommended to have multiple queue managers with the same name in a single network.
Using the wildcard in MQCONN
This is where a workaround using the “*” option on the MQCONN can come in. Imagine that we still have the same two queue managers called “DALE” on 9.9.9.9 and 8.8.8.8. But now, our client channel definition table contains:
1 : define channel(IN.SVRCONN.x) chltype(CLNTCONN) conname(9.9.9.9) qmname(FRED)
2 : define channel(IN.SVRCONN.y) chltype(CLNTCONN) conname(8.8.8.
qmname(BARNEY)
This gives us a number of options…
MQCONN(*FRED)
This will look up FRED in the QMNAME of the channel table. It will find a matching entry (1) and connect to it. On successful negotiation, we ignore the fact that the returned qmgr name (DALE) is different from what we connected to because of the ‘*’ prefix.
MQCONN(FRED)
This will look up FRED in the QMNAME of the channel table. It will find a matching entry (1) and connect to it. On successful negotiation, we see the fact that the returned qmgr name (DALE) is different from what we connected to and reject the connection.
MQCONN(*BARNEY)
This will look up BARNEY in the QMNAME of the channel table. It will find a matching entry (2) and connect to it. On successful negotiation, we ignore the fact that the returned qmgr name (DALE) is different from what we connected to because of the ‘*’ prefix.
MQCONN(BARNEY)
This will look up BARNEY in the QMNAME of the channel table. It will find a matching entry (2) and connect to it. On successful negotiation, we see the fact that the returned qmgr name (DALE) is different from what we connected to and reject the connection.
MQCONN(DALE)
This will look up DALE in the QMNAME of the channel table, find no matching entry and fail.
MQCONN("") or MQCONN(*)
This will look in the channel table for a QMNAME entry that is blank, find no matching entry and fail.
Note that these are all client bindings specific options (MQCONN will fail if a non-client application specifies a queue-manager name beginning with an asterisk).
Why you might want to use this
It has a number of uses, including the ability to solve the problem described above. It is not queue manager aliasing (that is something else), but it does have a similar sort of effect which the manuals refer to as “client queue manager groups”. Uses include where you have a client application which is only putting messages to any one of a group of queue managers, and it is not important to which queue manager a message is put.
For example, if you have a group of queue managers - all with different names and hosted on machines with different IP addresses - you can use QMNAME in the definitions of the client channels to identify them as being part of a single group:
define channel(IN.SVRCONN1) chltype(CLNTCONN) conname(9.9.9.1) qmname(MYQMGROUP)
define channel(IN.SVRCONN2) chltype(CLNTCONN) conname(9.9.9.2) qmname(MYQMGROUP)
define channel(IN.SVRCONN3) chltype(CLNTCONN) conname(9.9.9.3) qmname(MYQMGROUP)
define channel(IN.SVRCONN4) chltype(CLNTCONN) conname(9.9.9.4) qmname(MYQMGROUP)
define channel(IN.SVRCONN5) chltype(CLNTCONN) conname(9.9.9.5) qmname(MYQMGROUP)
define channel(IN.SVRCONN6) chltype(CLNTCONN) conname(9.9.9.6) qmname(MYQMGROUP)
If you want to connect to any queue manager in this group (regardless of what any of them are called), you can MQCONN to *MYQMGROUP.

8 comments
Comments feed for this article
February 27, 2007 at 6:41 am
Nigel Goddard
On my display the examples above show like this:
1 : define channel(IN.SVRCONN.x) chltype(CLNTCONN) conname(9.9
2 : define channel(IN.SVRCONN.y) chltype(CLNTCONN) conname(8.8.
so I cannot see the qmname which is the point of the example
February 27, 2007 at 10:14 am
Dale Lane
Thanks for pointing that out - it looks like an issue with the WordPress theme that we use, which causes a problem displaying text in <pre> tags in a browser’s default zoom setting. (zoom in or out and it seems to fix it)
I think that this must be a recent bug, because posts which previously looked fine including code snippets are now showing the same problem…
I’ve removed the pre tags from this post for now, so the lines should wrap instead.
edit: Fixed the CSS problem which caused this - should look okay again now. Thanks again, Nigel
February 27, 2007 at 1:47 pm
peterbroadhurst
Something worth adding is that when there are multiple entries with a matching QMNAME attribute, the client runs through these in a determinate (but undefined) order until it finds one that it can connect to (or runs out of entries and 2059s). See “MQ client queue-manager groups” in the description of MQCONN’s QMgrName param in the APR here. e.g. if the first CLNTCONN is not available, it will be still be tried first on every MQCONN call.
Also, something key to understand is that the CCDT (when being read by a client) is just a file. It’s created by a queue manager, but that can be any queue manager. At Version 6 it is a duplicate copy of object information contained inside the queue manager as well. This means that at Version 6 you cannot use runmqsc to edit a CCDT transferred from a different queue manager (which I know some people did at Version 5.3).
Anyone who’s interested in maintaining a complex CCDT file, worrying about the order in which entries are tried by a client, or needing to edit a CCDT file that you have (and no longer have the queue manager which created it) - take a look at the excellent MO72 SupportPac.
February 28, 2007 at 12:18 pm
protocol7 » Blog Archive » links for 2007-02-28
[...] Client Connection wildcards (tags: ibm websphere wmq ccdt mqi) [...]
May 17, 2007 at 8:00 pm
Joseph Gramig
Interesting, I’ve seen this used with MQCONN QMGR* to connect to one of several QMGRs that start with the same name. The order seemed to correlate to lexical order of the channel name in the channel table file.
Such that if I had the following:
define channel(IN.SVRCONN1) chltype(CLNTCONN) conname(9.9.9.1) qmname(QMGRB)
define channel(IN.SVRCONN2) chltype(CLNTCONN) conname(9.9.9.2) qmname(QMGRA)
The QMGRB would always be tried first.
June 4, 2007 at 7:05 pm
gtcarey
Dale can you expand upon your example for using MQ Client connections to groups of queue managers and how this could be set up for JMS API being used inside an AppServer by an MDB! If it can?
I am wondering if the MQCHLTAB and MQCHLLIB environment variables can be used by the JMS Listener portion of an MDB connecting to a remote queue manager and give it the same reconnection capabilities to the next queue manager in a AMQCLCHL.TAB file that you give in your example should one queue manager in group fail.
July 6, 2007 at 6:28 pm
Jeff Trimm
I am having an issue of using this technique with Pub/Sub running MQ 6.0.2.1. I set a wildcard QM name in the MQTopicConnectionFactory class. But when I attempt to subscribe to a topic, I get the exception:
com.ibm.mq.jms.BrokerCommandFailedException: Broker command failed: MQRCCF_Q_MGR_NAME_ERROR Reason code 3074
at com.ibm.mq.jms.MQBrokerSubscriptionEngine.openSubscription(MQBrokerSubscriptionEngine.java:355)
at com.ibm.mq.jms.MQMigrateSubscriptionEngine.openSubscription(MQMigrateSubscriptionEngine.java:200)
at com.ibm.mq.jms.MQSession.createTSubscriber(MQSession.java:4753)
at com.ibm.mq.jms.MQTopicSession.createSubscriber(MQTopicSession.java:590)
I have no problems using this technique to access Queues, or even to publish to Topics. Only when trying to subscribe to a topic.
October 19, 2007 at 3:28 am
Josh
This feature could be used to take advantage of an IP based load balancer by using the virtual IP in the CONNAME, or a DNS based load balancer by coding the dnsname. Has anyone tried this? I did a simple test and it worked as expected.