|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Simple JMS Put & get with selector WAS JMS get never rec |
« View previous topic :: View next topic » |
Author |
Message
|
arunakumarinampudi |
Posted: Thu Aug 15, 2013 12:33 pm Post subject: Simple JMS Put & get with selector WAS JMS get never rec |
|
|
 Novice
Joined: 27 Jul 2005 Posts: 11
|
I have very simple application, which puts a simple JMS Text message using JMS API on WebSphere MQ queue from WebSphere app Server (WPS 7.5) ... No issues, put works fine.
The message will go to another queue manager and processed by another JMS app running on WAS 6.0, sends reply back using JMS message replyToQueue and Reply to Queue Manager
I take the JMS Message ID, and construct a new JMS Consumer and with selector
Code: |
String selector = "JMSCorrelationID='" + msgId+ "'";
|
For some strange reason, the message never arrives within the time, for example if I set timeout in get as 3 seconds message will arrive in 4th second; and if I set timeout to 60 seconds, message will arrive on 61st second.
Once my app fails, I take the message Id from logs and run my JMS Get with that messageId, it works fine and gets the message.
But when I call my JMS Put & JMS Get from same application, my get never works.
I wondering if I am missing some JMS setting somewhere in WAS which is preventing JMS Get ...
Any help is highly appreciated ...
My JMS Get code is below ....
Code: |
javax.naming.Context ctx = new javax.naming.InitialContext();
javax.jms.ConnectionFactory connf = (javax.jms.ConnectionFactory) ctx.lookup(cf);
Destination dest = (Destination) ctx.lookup(jndiRecvQLookup);
javax.jms.Connection conn = connf.createConnection();
javax.jms.Session session = conn.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
String selector = "JMSCorrelationID='" + msgId "'";
System.out.println("MemberLookupEMPI.mqPutGetImpl.mqGet():Selector >>>>" + selector + "<<<<\n");
MessageConsumer consumer = session.createConsumer(dest, selector);
conn.start();
javax.jms.Message msg = consumer.receive(timeout);
System.out.println("MSG :" + msg);
System.out.println(" Close JMS Resources");
// conn.stop();
consumer.close();
session.close();
conn.close();
ctx.close();
connf = null;
|
|
|
Back to top |
|
 |
Vitor |
Posted: Thu Aug 15, 2013 12:39 pm Post subject: Re: Simple JMS Put & get with selector WAS JMS get never |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
arunakumarinampudi wrote: |
But when I call my JMS Put & JMS Get from same application, my get never works. |
Because the put and get are in the same unit of work, so the put of the message is not committed (and the message not available to the get) until the application ends.
arunakumarinampudi wrote: |
I wondering if I am missing some JMS setting somewhere in WAS which is preventing JMS Get ... |
Only if you're setting transactionality within JMS. If not, you're missing a setting somewhere else...  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Aug 15, 2013 1:15 pm Post subject: Re: Simple JMS Put & get with selector WAS JMS get never |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Vitor wrote: |
arunakumarinampudi wrote: |
But when I call my JMS Put & JMS Get from same application, my get never works. |
Because the put and get are in the same unit of work, so the put of the message is not committed (and the message not available to the get) until the application ends.
arunakumarinampudi wrote: |
I wondering if I am missing some JMS setting somewhere in WAS which is preventing JMS Get ... |
Only if you're setting transactionality within JMS. If not, you're missing a setting somewhere else...  |
Setting transactionality is all about this one.
A thing to keep in mind. WAS will overwrite the session transactionality depending on the existence of a parent / global transaction.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
arunakumarinampudi |
Posted: Thu Aug 15, 2013 1:20 pm Post subject: |
|
|
 Novice
Joined: 27 Jul 2005 Posts: 11
|
Thank you for very quick reply...
I am using non transacted session with auto ack....
Code: |
javax.naming.Context ctx = new javax.naming.InitialContext();
javax.jms.ConnectionFactory connf = (javax.jms.ConnectionFactory) ctx.lookup(cf);
Destination dest = (Destination) ctx.lookup(jndiSendQLookup);
Destination recv = (Destination) ctx.lookup(jndiRecvQLookup);
javax.jms.Connection conn = connf.createConnection();
javax.jms.Session session = conn.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(dest);
conn.start();
TextMessage tMsg = session.createTextMessage();
tMsg.setText(requestMsg);
tMsg.setJMSReplyTo(recv);
tMsg.setJMSDeliveryMode(javax.jms.DeliveryMode.NON_PERSISTENT);
producer.send(tMsg);
producer.send(tMsg);
producer.close();
session.close();
conn.close();
ctx.close();
connf = null;
|
Above code produce the message.... |
|
Back to top |
|
 |
arunakumarinampudi |
Posted: Fri Aug 16, 2013 7:01 am Post subject: |
|
|
 Novice
Joined: 27 Jul 2005 Posts: 11
|
My application started working after I changed the scope of the transaction ...
Its settings in WebSphere Integration Developer component level transaction boundary. I have to select "Local Application" instead of defaul Global.
Thanks for all the prompt help.... |
|
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
|
|
|
|