Author |
Message
|
vbajwa |
Posted: Wed Feb 07, 2007 12:49 pm Post subject: Connecting to ImqQueueManager using QM/host/port/CHL |
|
|
Newbie
Joined: 31 Jan 2007 Posts: 8
|
My program has to connect to three different QMs. From the API docs the ImqQueueManager only takes a QM name string. However the MQSERVER environment variable has to be set from outside like:
export MQSERVER="MY_CHANNEL/TCP/MY_HOSTNAME(portNum)"
Is there any programmatic way to specify these parameters as it not be possible to open more than 1 QM using the env. variable technique? I looked at the API docs in this forum, but no luck. And what is a local queue manager the docs talk about?
Thanks a lot for the info!
Vijay |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Feb 07, 2007 1:03 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/com.ibm.mq.amqzan.doc/amqzan09145.htm
Quote: |
ImqBoolean connect( );
Connects to the queue manager with the given ImqObject name, the default being the local queue manager. If you want to connect to a specific queue manager, use the ImqObject setName method before connection. If there is a channel reference, it is used to pass information about the channel definition to MQCONNX in an MQCD. The ChannelType in the MQCD is set to MQCHT_CLNTCONN. channel reference information, which is only meaningful for client connections, is ignored for server connections. The connect options affect the behavior of this method. This method sets the connection status to TRUE if successful. It returns the new connection status.
If there is a first authentication record, the chain of authentication records is used to authenticate digital certificates for secure client channels.
You can connect more than one ImqQueueManager object to the same queue manager. All use the same MQHCONN connection handle and share UOW functionality for the connection associated with the thread. The first ImqQueueManager to connect obtains the MQHCONN handle. The last ImqQueueManager to disconnect performs the MQDISC.
For a multithreaded program, each thread must use a separate ImqQueueManager object. Connections in different threads have different MQHCONN connection handles.
|
_________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
vbajwa |
Posted: Wed Feb 07, 2007 4:28 pm Post subject: |
|
|
Newbie
Joined: 31 Jan 2007 Posts: 8
|
Thanks for your reply! I learned something, but I still don't see how I can set hostname, port number and channel number.
Also, what exactly does it mean to say: "local queue manager" ?
Thanks!
Vijay |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Feb 07, 2007 7:10 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
vbajwa wrote: |
Thanks for your reply! I learned something, but I still don't see how I can set hostname, port number and channel number. |
Read up in the programer manual about MQCONNX...
A search in the infocenter should give you enough hits...
vbajwa wrote: |
Also, what exactly does it mean to say: "local queue manager" ? |
Read : The default being the local queue manager or the default being the qmgr you specified on the box you're executing on... _________________ MQ & Broker admin |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Feb 08, 2007 2:23 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Or set the client channel environment variables, and use the queue manager name to specify which entry from the table to use. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
vbajwa |
Posted: Thu Feb 08, 2007 8:42 am Post subject: |
|
|
Newbie
Joined: 31 Jan 2007 Posts: 8
|
OK, I think I got it, also found this useful bit of code. Thanks to all for pointing in the right direction. The link is: http://www.mqfaq.com/webspheremq.php
mgr.setName(argv[1]);
in_queue.setName(argv[2]);
out_queue.setName(argv[3]);
mgr.setName();
//Initialize channel values
//Warning: hard-coded values
channel.setChannelName("CHAN1");
channel.setTransportType( MQXPT_TCP );
channel.setConnectionName("10.40.60.68(1414)");
//Associate this channel with the queue manager
mgr.setChannelReference(channel);
//Connect to the queue manager
if ( !mgr.connect() ) {
... |
|
Back to top |
|
 |
|