Author |
Message
|
cart_chiu |
Posted: Wed Jun 30, 2004 7:39 am Post subject: Reading from remote queue |
|
|
Novice
Joined: 30 Jun 2004 Posts: 10
|
Hi, Is it possible to read from a remote queue? I have a remote definition of a queue. The queue resides on a different server other than my development machine.
If this is not possible, what are my options to retrieve messages from this remote queue? Does IBM provide some type of client? URLs would be appreciated.
Thanks in advance
Cart. |
|
Back to top |
|
 |
cart_chiu |
Posted: Wed Jun 30, 2004 7:54 am Post subject: Retrieving from remote queue |
|
|
Novice
Joined: 30 Jun 2004 Posts: 10
|
Here is the code that I have written. It fails with "com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2045"
Please excuse the ugly code. I'm just trying to find a quick and dirty way to pull the contents off of the queue.
Code: |
public String getMessageMQ() throws JMSException {
MQQueueManager qMgr = null;
byte[] message_Id = null;
String msgData = null;
MQQueue system_default_local_queue = null;
try {
MQEnvironment.channel = "SYSTEM.DEF.SVRCONN";
MQEnvironment.hostname = "10.1.1.118";
MQEnvironment.port = 1416;
// Create a connection to QManager
qMgr = new MQQueueManager("gmac.queue.manager");
// Set up the options on the Q we wish to open
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
// Now specify the Q that we wish to open and the open options
system_default_local_queue = qMgr.accessQueue("GMAC_RCVR_QUEUE1", openOptions);
MQMessage getMessage = new MQMessage();
MQGetMessageOptions gmo = new MQGetMessageOptions();
MQEnvironment.disableTracing();
MQException.log = null;
system_default_local_queue.get(getMessage, gmo);
// Close the Q
system_default_local_queue.close();
// Disconnect from QueueManager
qMgr.disconnect();
return getMessage.readUTF();
}
catch (MQException ex) {
System.out.println("A WebSphere MQ error occurred : Completion code " +
ex.completionCode + " Reason code " + ex.reasonCode);
ex.printStackTrace();
}
catch (Exception e) {
System.out.println("Exception caught");
e.printStackTrace();
}
return null;
}
|
|
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Jun 30, 2004 7:55 am Post subject: Re: Reading from remote queue |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
cart_chiu wrote: |
Hi, Is it possible to read from a remote queue? |
No.
Quote: |
I have a remote definition of a queue. The queue resides on a different server other than my development machine. |
Do you have a local queue manager on your development machine, then?
Quote: |
If this is not possible, what are my options to retrieve messages from this remote queue? Does IBM provide some type of client? |
Yes, IBM provides a client.
Your options are to make a client connection to the queue manager that has a local definition of the queue, or to configure MQSeries so that messages intended for your application will arrive on queues that are local to the queue manager your application is connected to.
I suggest you start looking at the Application Programming Guide, using the 'Documentation' button at the top of the screen. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
cart_chiu |
Posted: Wed Jun 30, 2004 10:43 am Post subject: Re: Reading from remote queue |
|
|
Novice
Joined: 30 Jun 2004 Posts: 10
|
jefflowrey wrote: |
cart_chiu wrote: |
Hi, Is it possible to read from a remote queue? |
No.
|
It's not at all possible or there's a way if I create a local queue manager?
jefflowrey wrote: |
cart_chiu wrote: |
I have a remote definition of a queue. The queue resides on a different server other than my development machine. |
Do you have a local queue manager on your development machine, then? |
Can I use JMSAdmin to create this? Does anyone know where I can find documentation on using this tool?
Quote: |
Quote: |
If this is not possible, what are my options to retrieve messages from this remote queue? Does IBM provide some type of client?
|
Yes, IBM provides a client.
|
Where can I find this client?
Quote: |
Your options are to make a client connection to the queue manager that has a local definition of the queue, or to configure MQSeries so that messages intended for your application will arrive on queues that are local to the queue manager your application is connected to.
I suggest you start looking at the Application Programming Guide, using the 'Documentation' button at the top of the screen. |
Ok, thanks for your help Jeff. I'll definitely start browsing this guide. |
|
Back to top |
|
 |
bower5932 |
Posted: Wed Jun 30, 2004 11:15 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
JMSAdmin is for the administration of JMS objects not for the creation of queue managers. You can find details on this command in the Using Java manual.
If you are doing your work in java/jms, then you probably already have the classes that will let you work as a client. You just need to make sure that you set up the MQEnvironment appropriately (which I believe you have in the code above).
I'm guessing that your 2045 is coming from the fact that you are attempting to open a queue that is defined as remote to the queue manager that you are connected to. |
|
Back to top |
|
 |
cart_chiu |
Posted: Wed Jun 30, 2004 12:08 pm Post subject: |
|
|
Novice
Joined: 30 Jun 2004 Posts: 10
|
bower5932 wrote: |
JMSAdmin is for the administration of JMS objects not for the creation of queue managers. You can find details on this command in the Using Java manual.
If you are doing your work in java/jms, then you probably already have the classes that will let you work as a client. You just need to make sure that you set up the MQEnvironment appropriately (which I believe you have in the code above). |
Thanks for the reply. This forum is great!
Quote: |
I'm guessing that your 2045 is coming from the fact that you are attempting to open a queue that is defined as remote to the queue manager that you are connected to. |
The queue manager is being defined using a .bindings file and use the Sun FS JNDI implementation (for the context). How do I check that it's defined this way? The queue manager is local to the queue I want to retrieve from.
The strange thing is that I am able to send messages to the queue without problem. I use the JMS API (as opposed to the MQ classes).
Now, when I try to retrieve from the same queue, this is when I get the 2045. Initially, I tried retrieving using JMS. That didn't seem to work and then I used the MQ classes. Then I get the same 2045 error.
Thanks so much for your help. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Jun 30, 2004 12:29 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
cart_chiu wrote: |
The strange thing is that I am able to send messages to the queue without problem. |
That's not strange, that's the way it works. You can only get messages from queues that are defined as local queues on the queue manager your application is connected to.
And as bower5932, JMSAdmin does not define any objects on your queue managers. It only defines references to objects in a JNDI lookup. If the objects being referenced don't exist, JMSadmin won't create them. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
cart_chiu |
Posted: Wed Jun 30, 2004 6:36 pm Post subject: Retrieving message from remote queue |
|
|
Novice
Joined: 30 Jun 2004 Posts: 10
|
Thanks guys for your help so far, it's appreciated.
Now, what I'm hearing is this:
1. A queue manager is only able to access queues local to it.
2. I need to create a client connection to the (remote) queue manager. Now, do I do this using JMS or the MQ classes or either one? Or do I have to use something like Websphere MQ Client?
Thanks again
Cart |
|
Back to top |
|
 |
vennela |
Posted: Thu Jul 01, 2004 4:45 am Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
Quote: |
Now, do I do this using JMS or the MQ classes or either one? |
Either one
Quote: |
Or do I have to use something like Websphere MQ Client?
|
NO, you don't need a Websphere MQ Client for an MQjava/JMS app |
|
Back to top |
|
 |
|