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 » Replyto in hierarchical MQ-topologies

Post new topic  Reply to topic
 Replyto in hierarchical MQ-topologies « View previous topic :: View next topic » 
Author Message
MichaelBulla
PostPosted: Wed Nov 01, 2006 6:26 am    Post subject: Replyto in hierarchical MQ-topologies Reply with quote

Apprentice

Joined: 27 Sep 2006
Posts: 31
Location: Hamburg/Germany

Hi,

Im building an hierarchical application using MQ. There are several BOCs (Back Office Controllers) which are under control of one CSS (Central Site Server) the BOCs communicate with the CSS using JMS-Messages.

On each BOC-MQ there is an CSS-Request Queue (remoteQueue to CSS's inQ) and an CSS-Reply Queue (local Queue). I want to send an request to the CSS and get back a reply in my Reply-Queue.

Here is my code on BOC side:
Code:

Queue senderQ = qsession.createQueue("requestQ");
Queue replyQ = qsession.createQueue("replyQ");
QueueSender sender = qsession.createSender(senderQ);
TextMessage message = qsession.createTextMessage("Hello CSS!");
message.setJMSReplyTo(replyQ);
sender.send(message);


On CSS-side:
Code:

public void onMessage(Message message) {
 Destination dest = message.getJMSReplyTo();
 MessageProducer sender = qsession.createProducer(dest);
 TextMessage repmessage = qsession.createTextMessage("Hello BOC");
 sender.send(repmessage);
}


If I let this run, I get an Exception:
Quote:
Fehler beim Empfangen einer Nachricht: javax.jms.InvalidDestinationException: MQJMS2008: Fehler beim Öffnen der MQ-Warteschlang replyQ
(Cant open queue "replyQ")

OK, the CSS has no replyQ. But I want to send the message, to the reply-Queue of the BOC. How do I do that? I cant define a remoteQueue, cause there are more than one reply-queues, to which one should the remote-queue point?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Nov 01, 2006 8:40 pm    Post subject: Reply with quote

Grand High Poobah

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

Your problem is most likely that you do not have a DEFAULT path from the CSS to each of the BOCs.
In order for the reply to destination to work you need that default path.
Read the intercommunications manual...+ section about qmgr alias

As well you did not extract the linked exception from your JMSException. My guess is it would have been a 2087(unknown remote qmgr).

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
MichaelBulla
PostPosted: Thu Nov 02, 2006 8:11 am    Post subject: Reply with quote

Apprentice

Joined: 27 Sep 2006
Posts: 31
Location: Hamburg/Germany

Thanks,

if read about intercommunication and got it now running.
If defined a TransmissionQ on CSS named BOC and changed the BOC code this way

Code:

Queue senderQ = qsession.createQueue("requestQ");
-> Queue replyQ = qsession.createQueue("queue://BOC/replyQ");
QueueSender sender = qsession.createSender(senderQ);
TextMessage message = qsession.createTextMessage("Hello CSS!");
message.setJMSReplyTo(replyQ);
sender.send(message);


This works fine, a little bit better was, if I didnt have to write the queuemanagers name in the reply-queue. Is it possible to tell the queuemanager or JMS to fill the queuename with the queuemanagers name (change replyQ -> "queue://BOC/replyQ")?

A step further:
Is it possible to let MQ create a whole routing for the wayback? I.e. I send a message from a POS (Point of sale) to CSS. The POSs are known by the the BOC, the BOCs are known by the CSS.
So I send the message from the POS to its BOC, I write in the message replyTo("queue:///replyQ")
At the BOC arrives replyTo("queue://POS1/replyQ"), this is send to CSS.
At the CSS arrives replyTo("queue://BOC02/POS1/replyQ").

I hope you understand, what I mean

Bye Michael[/b]
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Nov 02, 2006 3:22 pm    Post subject: Reply with quote

Grand High Poobah

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

Mein guter Freund Michael....
Sure I get what you mean.
Here is your scenario:
app1 on pos
app2 on boc
app3 on css

app1 sends a msg to boc and expects a reply
app2 forwards the msg to css and expects the reply
app3 processes the message and sends the reply to boc
app2 receives the message from css and forwards to pos
app1 receives its response.

Of course you may bypass app2 but then you would really want a cluster to lessen the maintenance for the channels...

The way I described it you just need a default path from:
  1. boc to css and pos
  2. css to boc

What you have are really 3 apps working in tandem
app1 does a request reply with app2
app2 takes the message form app1 and its process is to do a request reply with app3. When it receives the reply from app3 it uses the info in the message from app1 to send it the contents of the message received from app3(css)...

Exemple:
pos sends message with msgid 1 correlId 1
boc receives and forwards msgid 2 correlid 2
css receives and replies msgid 3 correlid 2
boc receives with correlid 2 and forwards msgid 4 correlid 1
pos receives with correlid 1

You could have a routing in 1 but it means a lot more channel maintenance ... this is why I brought up the cluster...

By the way there is no need to specify the qmgr when setting the reply to destination. The following code will default the qmgr to the qmgr of the connection that created the session...
Code:
 Queue myqueue = Session.createQueue("MYQUEUE");
mymsg.setJMSReplyTo(myqueue);


Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
MichaelBulla
PostPosted: Tue Nov 07, 2006 6:57 am    Post subject: Reply with quote

Apprentice

Joined: 27 Sep 2006
Posts: 31
Location: Hamburg/Germany

Hi saper,

Im surprised by your MQ- and germanlanguage-knowledge

Quote:
app1 sends a msg to boc and expects a reply
app2 forwards the msg to css and expects the reply
app3 processes the message and sends the reply to boc
app2 receives the message from css and forwards to pos
app1 receives its response.


You got it. And Step 4 is that one I want to abolish.
But the first problem is that, as you said, I would have many routes to define on CSS and second and much thats much worse: My POS-Names are not unique in the whole MQ-Network.
So if theres no way to define all the hops, that should be taken, I have to forward the messages by my application. I think I can live with it.

Quote:
By the way there is no need to specify the qmgr when setting the reply to destination. The following code will default the qmgr to the qmgr of the connection that created the session...
Code:
Queue myqueue = Session.createQueue("MYQUEUE");
mymsg.setJMSReplyTo(myqueue);


In my case this doesnt work: I use the code as described, but when I read out the message on CSS, it is:
JMSDestination: queue://CSS/inQ
JMSReplyTo: queue:///replyQ

Any idea?

Bye Michael
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Nov 07, 2006 7:29 pm    Post subject: Reply with quote

Grand High Poobah

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

This really depends on how you acquire the replyto destination.
If it is acquired via JNDI make sure a qmgr is specified in the JNDI and your destination will look fine.

My experience has been that if you do:
session.createQueue("queue:///myqueue");
the result will be in the destination something like "queue://myqmgr/myqueue"
This however may only be fully apparent once the message has been posted.
So in truth you would have to inspect the message on the destination host...

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
MichaelBulla
PostPosted: Fri Nov 17, 2006 7:52 am    Post subject: Reply with quote

Apprentice

Joined: 27 Sep 2006
Posts: 31
Location: Hamburg/Germany

OK, I've got it so far. But now I have the next problem.

I want to forward messages, when they cant be processed, but I get an exception. I do something like this on the BOC:

Code:
public void onMessage(Message message) {
 if (!canProcessMessage(message)) {
  message.setSomeProperties();
  MessageProducer css = session.createMessageProducer(css);
  css.send(message);
  producer.close();
 }
}


I get javax.jms.MessageNotWriteableException: MQJMS0008: JMS Client attempts to write a read-only message

I didnt find a method to "unlock" or copy the message. And I dont want to implement a copy-method on my own.

Is there a way to forward JMS-Messages?

Bye Michael
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Nov 17, 2006 8:23 pm    Post subject: Reply with quote

Grand High Poobah

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

The problem is that you are trying to add some properties to the message. Typically this would mean that you are changing the RFH2 inside the message and thus changing the message.

You would have to copy the message content and copy all the header properties... Another way is to just forward the message as is and create an additional message with correlid = bad msgid that may explain the error.

When your homegrown app looks at the bad message queue it picks the message and the one with the correlid and shows both. This way you will know why it failed...

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Replyto in hierarchical MQ-topologies
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.