Author |
Message
|
renrag_ja |
Posted: Thu Jan 07, 2010 6:01 pm Post subject: Howto specify RemoteQmgr/RemoteQ on an MQ message |
|
|
Newbie
Joined: 07 Jan 2010 Posts: 4
|
Hi Guys,
Whilst I only just registered, this forum has been a great help in the past. I did a search and I can't find exactly what I'm looking for, hence the first post.
I'd really appreciate some input on the following.
Situation:
QManagerA
QManagerB (remote queue manager definition)
QManagerB
QueueOnB (local queue)
Using a tool such as RFHUtil, I can connect to QManagerA via client connection, and specify the destination queue name as QueueOnB. It also lets me enter the queue manager QManagerB in the 'Remote Queue Manager Name (remote queues only)' field. Once I've done this, I write a message and see it arrive on QueueOnB on QManagerB.
My question is, how do I replicate the above functionality using Java code? I.e. I need to specify the destination Queue Manager in the message I'm sending (because it is not a Q local on the queue manager I'm connected to)
Thanks Guys. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Jan 07, 2010 6:43 pm Post subject: Re: Howto specify RemoteQmgr/RemoteQ on an MQ message |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
renrag_ja wrote: |
My question is, how do I replicate the above functionality using Java code? I.e. I need to specify the destination Queue Manager in the message I'm sending (because it is not a Q local on the queue manager I'm connected to) |
By specifying it as the destination? Seriously, it's that easy.
You say you have a "remote queue manager definition" of B on A; if this is what it should be (a transmission queue with the same name as the queue manager it serves) then WMQ will sort it all out even if there's no actual definition on A.
Check out some of the Java samples, and also review name resolution in the Intercommunication manual. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
renrag_ja |
Posted: Thu Jan 07, 2010 6:45 pm Post subject: |
|
|
Newbie
Joined: 07 Jan 2010 Posts: 4
|
After some more research, it seems that I need to set the ObjectQMgrName field in the MQOD. Can anyone provide some sample code so it is clear at what point during the message publishing this is done?
(btw, I'm using the jars from IBM WebSphere MQ, Version 6.0) |
|
Back to top |
|
 |
renrag_ja |
Posted: Thu Jan 07, 2010 6:51 pm Post subject: |
|
|
Newbie
Joined: 07 Jan 2010 Posts: 4
|
Thanks Vitor, you understand what I need to do which is great.
You say to specify it as the destination, but all the sample code I have looked at thus far calls accessQueue() on a qMgr object in order to perform the put (or get).
How would this work otherwise seeing as I can't call accessQueue() on a queue which doesn't exist on the local qMgr? (because it exists on QManagerB) |
|
Back to top |
|
 |
renrag_ja |
Posted: Thu Jan 07, 2010 6:59 pm Post subject: |
|
|
Newbie
Joined: 07 Jan 2010 Posts: 4
|
Something like this?
Code: |
MQQueueManager qMgr = new MQQueueManager(QManagerA)
...
MQQueue target_queue = qMgr.accessQueue("QueueOnB", openOptions, "QManagerB", null, null);
|
EDIT: This seems to work from what I've tested so far.
 |
|
Back to top |
|
 |
zpat |
Posted: Fri Jan 08, 2010 12:30 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Coding like this rather imbeds the remote queue information in the application.
It is better to use a remote queue definition on your local queue manager.
The program should ideally be unaware of whether it is putting to a local queue, or remote queue, or alias queue.
(An exception to this might be when replying to a request message and taking the queue manager name from the replytoqueuemanagername field.) |
|
Back to top |
|
 |
Vitor |
Posted: Fri Jan 08, 2010 6:10 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
renrag_ja wrote: |
How would this work otherwise seeing as I can't call accessQueue() on a queue which doesn't exist on the local qMgr? (because it exists on QManagerB) |
I'm the least qualified person round here to answer a Java question, but the accessQueue method takes a queue manager name as a parameter which I'd have thought would be the answer to your question.
I'll defer to more skilled Java people on this.
The comment about either using a queue definition to abstract the destination, or taking the value from an inbound request, is a very good one. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
nathanw |
Posted: Fri Jan 08, 2010 6:50 am Post subject: |
|
|
 Knight
Joined: 14 Jul 2004 Posts: 550
|
zpat wrote: |
Coding like this rather imbeds the remote queue information in the application.
It is better to use a remote queue definition on your local queue manager.
The program should ideally be unaware of whether it is putting to a local queue, or remote queue, or alias queue.
(An exception to this might be when replying to a request message and taking the queue manager name from the replytoqueuemanagername field.) |
The practice of having your app write to a remote queue all the time would mean that if there were any changes in the future then you would need to make several changes
It would be better to write to a remote queue definition locally and then this can ppoint to wherever you wish it to and any future changes as to destination would be easier to make. _________________ Who is General Failure and why is he reading my hard drive?
Artificial Intelligence stands no chance against Natural Stupidity.
Only the User Trace Speaks The Truth  |
|
Back to top |
|
 |
|