Author |
Message
|
techno |
Posted: Wed Feb 04, 2004 9:55 pm Post subject: Multiple qmgrs |
|
|
Chevalier
Joined: 22 Jan 2003 Posts: 429
|
Can a program connect to more than one qmgrs?
Thanks. |
|
Back to top |
|
 |
MQRR |
Posted: Wed Feb 04, 2004 10:19 pm Post subject: |
|
|
Centurion
Joined: 10 Aug 2003 Posts: 110
|
I dont think that is possible. |
|
Back to top |
|
 |
fschofer |
Posted: Thu Feb 05, 2004 4:38 am Post subject: |
|
|
 Knight
Joined: 02 Jul 2001 Posts: 524 Location: Mainz, Germany
|
Sure its possible to connect several queue managers from one program.
In a java program for example you can instantiate several threads of which each connects to a different qmgr.
Take a look in the Application Programming Guide for further information. |
|
Back to top |
|
 |
techno |
Posted: Thu Feb 05, 2004 8:03 am Post subject: |
|
|
Chevalier
Joined: 22 Jan 2003 Posts: 429
|
So, a thread can connect to one qmgr!
Hey, From clients doc, I have seen: A program connecting to more than one qmgr thru client connections. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Feb 05, 2004 8:15 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
techno wrote: |
So, a thread can connect to one qmgr! |
Yes. As a basic rule, no more than one connection per thread is allowed.
You can, in 5.3, create shared connections that can be passed between threads (at least in some of the APIs).
In 5.2 and earlier, you could not share a connection between two threads. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
techno |
Posted: Thu Feb 05, 2004 10:56 pm Post subject: |
|
|
Chevalier
Joined: 22 Jan 2003 Posts: 429
|
How about MQCONNX. This has the options for sharing the handle. This should be there even in 5.2 |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Feb 06, 2004 6:56 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
techno wrote: |
This has the options for sharing the handle. This should be there even in 5.2 |
No, I don't think the option for sharing a handle was available in 5.2.
But that's from memory, not from double-checking the manuals. Which is just as easy for you to do as it is for me to do. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
vennela |
Posted: Fri Feb 06, 2004 8:57 am Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
You can connect to more than one queue manager in a program.
This one worked for me. No threads. Just a small java app
Code: |
import com.ibm.mq.*;
public class mqclientto2qmgrs extends Object {
/** Creates new MQPut */
public mqclientto2qmgrs() {
}
/**
* @param args the command line arguments
*/
public static void main (String args[]) {
try {
String QM1 = "SSPQM";
String QUEUE1 = "SYSTEM.DEFAULT.LOCAL.QUEUE";
System.out.println("Starting MQClientPut Program: ");
MQEnvironment.hostname = "host1";
MQEnvironment.channel = "SYSTEM.DEF.SVRCONN";
MQEnvironment.port = 1414;
MQQueueManager qmgr = new MQQueueManager("QM1" ) ;
System.out.println("Connected to QMGR QM1");
int openOptions = MQC.MQOO_OUTPUT;
MQQueue InQueue = qmgr.accessQueue(QUEUE1 , openOptions, null, null, null);
MQMessage inMessage = new MQMessage();
inMessage.writeString("What is your name");
InQueue.put(inMessage);
System.out.println("Message Id is :" + inMessage.messageId);
MQEnvironment.hostname = "host2";
MQEnvironment.channel = "SYSTEM.DEF.SVRCONN";
MQEnvironment.port = 1414;
MQQueueManager qmgr1 = new MQQueueManager("QM2" ) ;
System.out.println("Connected to QMGR QM2");
MQQueue InQueue1 = qmgr1.accessQueue(QUEUE1 , openOptions, null, null, null);
InQueue1.put(inMessage);
System.out.println("Message Id is :" + inMessage.messageId);
InQueue.close();
InQueue1.close();
qmgr1.disconnect() ;
qmgr.disconnect() ;
}
catch(MQException ex){
System.out.println("MQ Error - Reason code :" + ex.reasonCode);
}
catch (Exception e){
System.out.println("Error : " + e);
}
}
} |
|
|
Back to top |
|
 |
EddieA |
Posted: Fri Feb 06, 2004 9:45 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
That's because your Java program is connecting as a Client. You have always been able to make a Client connect to multiple Queue Managers.
The trick has always been, how to do this in Bindings mode.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
PeterPotkay |
Posted: Fri Feb 06, 2004 1:08 pm Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
I have VB.NET program that is a little testing tool. I have coded it such that it creates a new queue manager object evry time you click connect, and you can specify bindings or client mode. If you select client, my gui allows you to then set connection info.
I have connected to 20 QMs at the same time, or to the same QM 20 times, in both bindings mode and / or client mode. _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
vennela |
Posted: Fri Feb 06, 2004 2:09 pm Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
OK
Tested the same with a java app. Connected to two QMGRs in bindings mode.
Code: |
import com.ibm.mq.*;
public class mqpgmto2qmgrs extends Object {
/** Creates new MQPut */
public mqpgmto2qmgrs() {
}
/**
* @param args the command line arguments
*/
public static void main (String args[]) {
try {
String QM1 = "SSPQM";
String QUEUE1 = "SYSTEM.DEFAULT.LOCAL.QUEUE";
System.out.println("Starting MQClientPut Program: ");
MQQueueManager qmgr = new MQQueueManager("QM1" ) ;
System.out.println("Connected to QMGR QM1");
int openOptions = MQC.MQOO_OUTPUT;
MQQueue InQueue = qmgr.accessQueue(QUEUE1 , openOptions, null, null, null);
MQMessage inMessage = new MQMessage();
inMessage.writeString("What is your name");
InQueue.put(inMessage);
System.out.println("Message Id is :" + inMessage.messageId);
MQQueueManager qmgr1 = new MQQueueManager("QM2" ) ;
System.out.println("Connected to QMGR QM2");
MQQueue InQueue1 = qmgr1.accessQueue(QUEUE1 , openOptions, null, null, null);
InQueue1.put(inMessage);
System.out.println("Message Id is :" + inMessage.messageId);
InQueue.close();
InQueue1.close();
qmgr1.disconnect() ;
qmgr.disconnect() ;
}
catch(MQException ex){
System.out.println("MQ Error - Reason code :" + ex.reasonCode);
}
catch (Exception e){
System.out.println("Error : " + e);
}
}
}
|
|
|
Back to top |
|
 |
techno |
Posted: Sat Feb 07, 2004 8:56 am Post subject: |
|
|
Chevalier
Joined: 22 Jan 2003 Posts: 429
|
|
Back to top |
|
 |
techno |
Posted: Sat Feb 07, 2004 1:04 pm Post subject: |
|
|
Chevalier
Joined: 22 Jan 2003 Posts: 429
|
Looks like there is some confusion.
1. Sharing Connection among number of threads
2. Having connections to multiple qmgrs in a single thread.
1 and 2 both depend on environments
In general scope of a connection is just one thread.
In Application Programming Guide Manual:
Each thread can connect to a different queue manager using MQCONN or
MQCONNX on OS/2 and Windows systems, but not on OS/400 or UNIX.
If your application is running as a client, it may connect to more than one queue manager within a thread.
Vennela
Which environment you tried that code? |
|
Back to top |
|
 |
vennela |
Posted: Sat Feb 07, 2004 1:59 pm Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
On Win XP
Code: |
Name: WebSphere MQ
Version: 530.4 CSD04
CMVC level: p530-04-030617
BuildType: IKAP - (Production) |
Code: |
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode) |
|
|
Back to top |
|
 |
|