Author |
Message
|
andrey81inmd |
Posted: Tue Jul 19, 2005 9:58 am Post subject: Sending messages to a cluster queue |
|
|
Novice
Joined: 19 Jul 2005 Posts: 17
|
Hello,
I'm trying to write a Java program that sends a message to a cluster queue, let's call it Q1.
We have 2 cluster queue managers: QM1 and QM2. Q1 is hosted on QM1 and Q2 is hosted on QM2. Both Q1 and Q2 show up as cluster queues on my local machine. I want to send a message specifically to Q1. I have only one transmit queue: SYSTEM.CLUSTER.TRANSMIT.QUEUE. When I send a message to the xmit queue, it just stays there. I send the message in a way I would normally send it to a local queue.
My question is: how do I tell the xmit queue where my message is supposed to go: Q1 or Q2? I need to do this from Java. Thanks. |
|
Back to top |
|
 |
mq_crazy |
Posted: Tue Jul 19, 2005 10:05 am Post subject: |
|
|
 Master
Joined: 30 Jun 2004 Posts: 295
|
You shoudn't send a message to the transmit queue. You have to publish the message as a local queue, so in the code you say publish the messages to Q1 on QM1 as if Q1 is a local queue and MQ will take care of moving the message where the queue hosts |
|
Back to top |
|
 |
andrey81inmd |
Posted: Tue Jul 19, 2005 10:21 am Post subject: |
|
|
Novice
Joined: 19 Jul 2005 Posts: 17
|
mq_crazy wrote: |
You shoudn't send a message to the transmit queue. You have to publish the message as a local queue, so in the code you say publish the messages to Q1 on QM1 as if Q1 is a local queue and MQ will take care of moving the message where the queue hosts |
That doesn't work, though. It's not a "local clustered" queue, it's a "cluster" queue. I get an exception: "cannot open queue" |
|
Back to top |
|
 |
mq_crazy |
Posted: Tue Jul 19, 2005 10:25 am Post subject: |
|
|
 Master
Joined: 30 Jun 2004 Posts: 295
|
is your local machine part of the cluster??? |
|
Back to top |
|
 |
andrey81inmd |
Posted: Tue Jul 19, 2005 10:38 am Post subject: |
|
|
Novice
Joined: 19 Jul 2005 Posts: 17
|
mq_crazy wrote: |
is your local machine part of the cluster??? |
Yes, but it's not the host of this queue |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jul 19, 2005 10:41 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
What are your open options?
You should be able to open the clustered queue, and then put a message that indicates QM1 in the MQMD.
Are you using JMS? Or the MQ API for Java? If using the plain Java API, then what is the Reason Code you are getting? If using JMS, then what is the linked exception you are getting, which will include the Reason Code? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
andrey81inmd |
Posted: Tue Jul 19, 2005 11:07 am Post subject: |
|
|
Novice
Joined: 19 Jul 2005 Posts: 17
|
Here's a piece of my code:
factory = new MQQueueConnectionFactory();
((MQQueueConnectionFactory) factory).setQueueManager(QM1);
connection = factory.createQueueConnection();
boolean transacted = false;
session = connection.createQueueSession(transacted, Session.AUTO_ACKNOWLEDGE);
outQueue = session.createQueue(Q1);
queueSender = session.createSender(outQueue);
queueSender.setDeliveryMode( DeliveryMode.PERSISTENT );
outMessage = session.createTextMessage();
outMessage.setText(messageData);
queueSender.send(outMessage);
I get the following exception: cannot open MQ Queue (or something to that effect, I cant run this right now because I cant log in to our test env) |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jul 19, 2005 11:59 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
So you're using JMS, and so you'll need to catch the Linked Exception to see what's really going on. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Jul 19, 2005 12:18 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
andrey81inmd wrote: |
Here's a piece of my code:
factory = new MQQueueConnectionFactory();
((MQQueueConnectionFactory) factory).setQueueManager(QM1);
connection = factory.createQueueConnection();
boolean transacted = false;
session = connection.createQueueSession(transacted, Session.AUTO_ACKNOWLEDGE);
outQueue = session.createQueue(Q1);
queueSender = session.createSender(outQueue);
queueSender.setDeliveryMode( DeliveryMode.PERSISTENT );
outMessage = session.createTextMessage();
outMessage.setText(messageData);
queueSender.send(outMessage);
I get the following exception: cannot open MQ Queue (or something to that effect, I cant run this right now because I cant log in to our test env) |
This is the offending code: outQueue = session.createQueue(Q1);
use :
Code: |
outQueue = session.createQueue("queue://QM1/Q1"); |
The way you did the open there is no telling which hosting qmgr will get the message. The way I described you are forcing the message to go to QM1. Sometimes a cluster alias is used and the queue is defined with the cluster alias.
you could as well try:
Code: |
outQueue = session.createQueue("queue:///Q1"); |
(blank qmgr)
Enjoy  |
|
Back to top |
|
 |
andrey81inmd |
Posted: Tue Jul 19, 2005 1:35 pm Post subject: |
|
|
Novice
Joined: 19 Jul 2005 Posts: 17
|
But I did this:
((MQQueueConnectionFactory) factory).setQueueManager(QM1);
This sets the Queue Manager. What's the difference? |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Jul 19, 2005 9:10 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
andrey81inmd wrote: |
But I did this:
((MQQueueConnectionFactory) factory).setQueueManager(QM1);
This sets the Queue Manager. What's the difference? |
The difference should be setQueueManager("QM1");
QM1 is an unknown variable/object with possible value null(?). I am surprised that you can even open the QueueConnection.
The other part is that you provide an url type resource. This will create the resource even if it does not exist on the qmgr. A little like if it had been created in JNDI and retrieved. To access the resource you will still have to go through the qmgr but the queue defined this way does not have to exist on the qmgr.
Please provide the linked exception it will tell much more about what is wrong.
Not specifying a qmgr may have the system assume it is by default the one you are connected to. This is why if you have a cluster alias defined to the cluster that blanks out the qmgr name you can use it when defining cluster queue in JMS. Standard routing will then blank out the qmgr and the message will follow the cluster patterns for routing.
Enjoy  |
|
Back to top |
|
 |
Nigelg |
Posted: Wed Jul 20, 2005 4:24 am Post subject: |
|
|
Grand Master
Joined: 02 Aug 2004 Posts: 1046
|
The rules for queue name resolution are in a table in the APG (qv). |
|
Back to top |
|
 |
andrey81inmd |
Posted: Wed Jul 20, 2005 11:07 am Post subject: |
|
|
Novice
Joined: 19 Jul 2005 Posts: 17
|
Thanks to everyone for trying to help. As usual with MQ and WebSphere, this turned out to be a configuration problem. I'm a programmer so I dont really know what the admins did, but they basically separated one cluster into two, and now my code works as intended.
By the way, when I say QM1, I really mean that QM1 is a String variable containing the name of the queue manager. So there's no need to put it in quotes. |
|
Back to top |
|
 |
|