|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Servlet and MQ with JMS |
« View previous topic :: View next topic » |
Author |
Message
|
mckay |
Posted: Mon Aug 27, 2007 9:49 pm Post subject: Servlet and MQ with JMS |
|
|
Newbie
Joined: 27 Aug 2007 Posts: 4
|
Hi.
I'm using JMS in a servlet to send a message to an EJB using MQ connection resources in WAS 5 server. The servlet is called by a jsp form, forms an XML structure with the params obtained from the request object, and this XML is setted as the text of a Message object that it is sent to an EJB using the MQ resources in the WAS. The EJB responses back to the servlet with another XML structure that it is read by the browser to show it's content.
My problem is that every time I submit the jsp form to start the flow, I'm getting the data from a previous input, for example, if I submit the jsp for the first time, the flow is fine, but if a user clicks the back button of the browser and inputs new data and submits the form, the response that receives is from the first input. It happens even without clicking the browser's back button, posting the URL directly in the browser and even refreshing the URL. I've noticed that I'm receiving some responses from messages that I'm not sending (another user testing the flow in a different machine/browser). So this is my general scenario and I haven't been able to find a solution, and I already passed the project's deadline, so, I guess I'm in an urgent situation. Please, feel free to post any suggestion, idea, tip, etc.
Carlos |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Aug 28, 2007 3:35 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
It sounds like you're caching things you shouldn't be caching...
Also, if you're not getting the right response for your request, then you can't have a proper request/reply pattern in place. Use the msgId of the request to match the CorrelId of the reply. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mckay |
Posted: Tue Aug 28, 2007 7:11 am Post subject: |
|
|
Newbie
Joined: 27 Aug 2007 Posts: 4
|
Hi, jefflowrey.
I'm already setting the correlation Id in my replier object, with the messageId of the requestor, like this:
TextMessage replyMessage = session.createTextMessage();
replyMessage.setText(contents);
replyMessage.setJMSCorrelationID(requestMessage.getJMSMessageID());
replyProducer.send(replyMessage);
Is this correct, according to your suggestions?
Carlos |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Aug 28, 2007 8:11 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Okay.
Are you also setting and then using the ReplyToQueue/ReplyToQueueManager?
If you're doing both of those, then you should not be getting the wrong response. Unless you're generating duplicate messageIDs on the request.
Or not using the CorrelationID to get the response message. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mckay |
Posted: Tue Aug 28, 2007 8:26 am Post subject: |
|
|
Newbie
Joined: 27 Aug 2007 Posts: 4
|
Hello again.
Thank you for your help. Yes, in my requestor object I'm using the following:
TextMessage outMessage =session.createTextMessagexmlMessAux.toString());
outMessage.setJMSReplyTo(inQueue);
then, I extract this queue in the replier object and use it to set the queue destination for the response message.
How could I validate that I'm not generating duplicate messagesID's?
Carlos |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Aug 28, 2007 8:29 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Sorry. I forgot. You're using JMS, so it always generates a unique message ID for you. (thankfully).
Are you using the correlationID in a selector when getting the response? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mckay |
Posted: Tue Aug 28, 2007 9:23 am Post subject: |
|
|
Newbie
Joined: 27 Aug 2007 Posts: 4
|
Hello again.
I think it's solved. I wasn't setting the selector in the queue receiver, like this:
QueueReceiver queueReceiver = session.createReceiver(jndiInQueue, selector);
instead, I was just only setting the queue. I'm testing the change but I think it's ok now.
Thanks for your help, man!
Carlos |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|