Author |
Message
|
mikivin |
Posted: Thu Apr 06, 2006 6:58 am Post subject: Obtain cluster queue |
|
|
Novice
Joined: 06 Apr 2006 Posts: 10
|
Hi,
I'm new to WebSphere MQ world.My question is:
I have some queue managers (QM1,QM2...) on different machines in one cluster. I create cluster queue Q1. I need put/get messages to Q1 from all queue managers in the cluster by JMS. I connect to JNDI this way:
java.util.Hashtable environment = new java.util.Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY, ""com.ibm.mq.jms.context.WMQInitialContextFactory"");
environment.put(Context.PROVIDER_URL, ""localhost:LISTENER_PORT/SERVER_CONNECTION_CHANNEL");
Context ctx = new InitialContext(environment);
QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup(QMXXX);
QueueConnection conn = factory.createQueueConnection();
QueueSession session = conn.createQueueSession(true,Session.AUTO_ACKNOWLEDGE);
Queue queue = (Queue)ctx.lookup(Q1);
I get exception : Object not found
I cant find cluster queue Q1 on all queue managers except one queue manager where is local queue (when luster queue created).
How can I put/get messages to Q1 from all queue managers in the cluster by JMS ? Maybe I should connect to JNDI another way?Any suggestion ?
Thanks in advance.
Miki |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Apr 06, 2006 7:00 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You will only ever be able to GET messages if you are connected directly to the qmgr that has Q1 as a qlocal.
You will be able to PUT to Q1 from any queue manager in the cluster, regardless of whether or not you can "see" it. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mikivin |
Posted: Thu Apr 06, 2006 7:15 am Post subject: |
|
|
Novice
Joined: 06 Apr 2006 Posts: 10
|
jefflowrey wrote: |
You will only ever be able to GET messages if you are connected directly to the qmgr that has Q1 as a qlocal.
You will be able to PUT to Q1 from any queue manager in the cluster, regardless of whether or not you can "see" it. |
But I can't get cluster queue by lookup. How I can put mesage ? |
|
Back to top |
|
 |
Vitor |
Posted: Thu Apr 06, 2006 7:28 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Take pity on a man with very little Java - what do mean by lookup? In JNDI the queue is a location which in this case resolves to a cluster queue. So long as the queue manager you're connected to is part of the cluster you can put to it. As jefflowery correctly points out, you can only get from the local instance of a cluster queue, if there is one.
It's a common trick (pre-v6.0) to put from a queue manager that does not have a local queue to use workload balancing; at that level messages always went to the local copy of a cluster queue if there was one. Post v6.0 it's a bit more sophisticated (I'm told).
Please explain more clearly what you mean by lookup, with particular reference with what I got wrong in my description. Java / JNDI is not my happy place! _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Apr 06, 2006 7:29 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You have made several design decisions without understanding them.
You have decided to use Clusters without understanding the basics of clustering - including that you can only GET from qlocals and that qclusters are only "visible" to partial repositories if an application has issued a PUT against that qcluster already. That's why it's a partial repository - becuase it only holds the entries that it needs to hold but can look up any entries it doesn't know about from the full repositories.
You have decided to use the queue manager as your JNDI repository, rather than using an application server JNDI store or a database or a flatfile or etc - without understanding what information the queue manager has available to it at what times.
So do you want help reconsidering your design decisions, or do you want help applying kludges to your system so that your design decisions will work? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mikivin |
Posted: Sun Apr 09, 2006 12:04 am Post subject: |
|
|
Novice
Joined: 06 Apr 2006 Posts: 10
|
Thanks to You for previous answers.
My design is : several queue managers on different machines( Websphere Brokers). They used same queue. I supposed to put all queue managers in cluster, create cluster queue to putting/getting messages.
Application that running on same machine where queue manager installed
using JMS to put/get messages to/from cluster queue. So we have one queue shared to all machines.
I understand that I can't get message from remoted queue managers .
What its better design to have common queue to distributed queue managers(different machines, diferrent brokers).
I write followwing code Java to put/get messages:
Context ctx = new InitialContext(environment);
QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup(cf);
Queue queue = (Queue)ctx.lookup(Q1); - I cant get cluster queue on distributed queue managers
How can I create cluster queue on distributed machines ?
Any another solution ?
Thanks in advance. |
|
Back to top |
|
 |
jefflowrey |
Posted: Sun Apr 09, 2006 10:20 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
It is perfectly normal and perfectly reasonable design to host multiple copies of a queue in a cluster, and attach different copies of an application to each of those queues.
This is not your problem.
Where is your JNDI information being stored?
Your first post said you were using "com.ibm.mq.jms.context.WMQInitialContextFactory".
What do you think that means? How do you think that is affected by what queue manager you are connected to? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|