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 Java / JMS » Dynamic reply mechanism

Post new topic  Reply to topic
 Dynamic reply mechanism « View previous topic :: View next topic » 
Author Message
kordi
PostPosted: Fri Apr 17, 2015 12:36 pm    Post subject: Dynamic reply mechanism Reply with quote

Centurion

Joined: 28 May 2012
Posts: 145
Location: PL

Hi guys,

I am wondering how actually dynamic replies looks like. It is pretty clear for me how to use remote queues to send message to remote local queue but I don't exactly know how it is done without qremote.

Here is piece of code. Can you please help me with missing elements?

Code:

    System.out.println("Connecting to queue manager: " + qManager);
    MQQueueManager qMgr = new MQQueueManager(qManager);

    // Set up the options on the queue we wish to open
   int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF | MQConstants.MQOO_OUTPUT;
      
    // Now specify the queue that we wish to open and the open options
    System.out.println("Accessing queue: " + qGetName);
    MQQueue queue = qMgr.accessQueue(qGetName, openOptions);

    // Now get the message off the queuen. First define a WebSphere MQ message to receive the data
   MQMessage rcvMessage = new MQMessage();

     // Specify default get message options
     MQGetMessageOptions gmo = new MQGetMessageOptions();

    // Get the message off the queue.
    System.out.println("Getting the message from queue...");
    queue.get(rcvMessage, gmo);
   
   String ReplyToQ = rcvMessage.replyToQueueName;
   String ReplyToQmgr = rcvMessage.replyToQueueManagerName;
   
   // and now I want to process message and send this message back to ReplyToQ and ReplyToQueueManager destination with no use of remote queue
   // What queue to open? What headers to set?


Thanks in advance!
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Apr 18, 2015 11:14 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

The signature of accessQueue you used is not the only signature. Explore further...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
RogerLacroix
PostPosted: Mon Apr 20, 2015 12:23 pm    Post subject: Re: Dynamic reply mechanism Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3252
Location: London, ON Canada

kordi wrote:
Code:
    // Set up the options on the queue we wish to open
   int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF | MQConstants.MQOO_OUTPUT;

If you are only reading from that queue then you should NOT open for both input and output (and add fail if quescing).
i.e.
Code:
int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF | MQConstants.MQOO_FAIL_IF_QUIESCING


kordi wrote:
I am wondering how actually dynamic replies looks like. It is pretty clear for me how to use remote queues to send message to remote local queue but I don't exactly know how it is done without qremote.

There is nothing special about a (temporary) dynamic queue. How would you open a local queue?

Regards,
Roger Lacroix
Capitalware Inc.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
kordi
PostPosted: Mon Apr 20, 2015 2:05 pm    Post subject: Re: Dynamic reply mechanism Reply with quote

Centurion

Joined: 28 May 2012
Posts: 145
Location: PL

RogerLacroix Thank you for the tips. I am struggling to figure out how to use so called "dynamic replies" which are familiar with COA or COD.

When we use COA or COD we need to define xmitq with the same name as q manager to which those reports should arrive (and respective channel of course).

What I dont know is how should reply to request looks like, when no qremote exist, only xmitq named as remote q manager and channel using this xmitq.

Please take a look at my piece of code.

What I tried was to put reply to xmitq directly (message went to DLQ) and I also put message to SYSTEM.DEFAULT.MODEL.QUEUE and this message was gone.

How I should reply to request, using no qremote, to deliver this message to ReplyToQ and ReplyToQmgr? I much appreciate code sample because I know how it works "in theory".

Many thanks.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Apr 21, 2015 4:59 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

First READ this http://www-01.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q033830_.htm

Then think about what you are going to put into each of the fields for following method call:

Code:
MQQueue replyqueue= MQQueueManager.AccessQueue(Name$, OpenOptions&, QueueManagerName$, DynamicQueueName$, AlternateUserId$);


like

Code:
replyqueue= MQQueueManager.AccessQueue(replytoqname, MQOO_options, replytoqmgrname, null, null);


Also have a look at the different parameters on the qmgr.put method... ()

And just for clarification MQQueueManager is the queue manager you are connected to and not a static reference to the class.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kordi
PostPosted: Wed Apr 22, 2015 1:05 pm    Post subject: Reply with quote

Centurion

Joined: 28 May 2012
Posts: 145
Location: PL

fjb_saper Thank you, this is it. This is what I was looking for, my piece of code is now working as expected.

The problem was that I assumed there are no more parameters in AccessQueue method. Thanks again!
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Apr 23, 2015 4:59 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

kordi wrote:
fjb_saper Thank you, this is it. This is what I was looking for, my piece of code is now working as expected.

The problem was that I assumed there are no more parameters in AccessQueue method. Thanks again!

Well, If you had read my first post you would have had the answer 5 days ago!
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kordi
PostPosted: Thu Apr 23, 2015 9:49 am    Post subject: Reply with quote

Centurion

Joined: 28 May 2012
Posts: 145
Location: PL

Yeah but I wasn't really sure what did you mean by "signature"
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Apr 23, 2015 11:48 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

kordi wrote:
Yeah but I wasn't really sure what did you mean by "signature"

In Java the "signature" of a Method shows how the method is defined:
Return parameter, method name, parameters with type...

So you may have the same method with different signature. It's called overloading...
http://java.about.com/od/m/g/methodsignature.htm
https://docs.oracle.com/javase/tutorial/java/javaOO/methods.html


Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kordi
PostPosted: Thu Apr 23, 2015 12:30 pm    Post subject: Reply with quote

Centurion

Joined: 28 May 2012
Posts: 145
Location: PL

I have read and remembered. Bacame a bit smarter now

Thank you.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Dynamic reply mechanism
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.