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 » IBM MQ API Support » Multiple qmgrs

Post new topic  Reply to topic
 Multiple qmgrs « View previous topic :: View next topic » 
Author Message
techno
PostPosted: Wed Feb 04, 2004 9:55 pm    Post subject: Multiple qmgrs Reply with quote

Chevalier

Joined: 22 Jan 2003
Posts: 429

Can a program connect to more than one qmgrs?

Thanks.
Back to top
View user's profile Send private message
MQRR
PostPosted: Wed Feb 04, 2004 10:19 pm    Post subject: Reply with quote

Centurion

Joined: 10 Aug 2003
Posts: 110

I dont think that is possible.
Back to top
View user's profile Send private message
fschofer
PostPosted: Thu Feb 05, 2004 4:38 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
techno
PostPosted: Thu Feb 05, 2004 8:03 am    Post subject: Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Thu Feb 05, 2004 8:15 am    Post subject: Reply with quote

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
View user's profile Send private message
techno
PostPosted: Thu Feb 05, 2004 10:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Fri Feb 06, 2004 6:56 am    Post subject: Reply with quote

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
View user's profile Send private message
vennela
PostPosted: Fri Feb 06, 2004 8:57 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
EddieA
PostPosted: Fri Feb 06, 2004 9:45 am    Post subject: Reply with quote

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
View user's profile Send private message
PeterPotkay
PostPosted: Fri Feb 06, 2004 1:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
vennela
PostPosted: Fri Feb 06, 2004 2:09 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
techno
PostPosted: Sat Feb 07, 2004 8:56 am    Post subject: Reply with quote

Chevalier

Joined: 22 Jan 2003
Posts: 429

What version is it?
Back to top
View user's profile Send private message
techno
PostPosted: Sat Feb 07, 2004 1:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
vennela
PostPosted: Sat Feb 07, 2004 1:59 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » Multiple qmgrs
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.