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 » Problem with JMS MessageSelector and native MQ.

Post new topic  Reply to topic
 Problem with JMS MessageSelector and native MQ. « View previous topic :: View next topic » 
Author Message
jborella
PostPosted: Mon Aug 05, 2013 1:09 am    Post subject: Problem with JMS MessageSelector and native MQ. Reply with quote

Apprentice

Joined: 04 Jun 2009
Posts: 26

I want to be able to use JMS for programming a Java Client to communicate with a native MQ application in a request/reply scenario. The native MQ application doesn't support RFH2 headers. Unfortunately I'm experiencing some problems. I've made a little proof where I:
1. Write a message on a queue, setting the JMSCorrelationID.
2. Wait for a reply on a queue, selecting the JMSCorrelationID set in step 1.

According to the MQ documentation (http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic=%2Fcom.ibm.mq.csqzaw.doc%2Fjm24450_.htm), this should be possible even when communicating with a native MQ application, because the JMS header are translated to/from the MQMD header.

In code I've done the following on the sender side:
Code:

//omitted some code to setup the connection (oldschool jndi)
Connection connection = cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("TEST.REQUEST");
//the following line forces writing without usingJMS headers, would like an alternative
((com.ibm.mq.jms.MQQueue) queue).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);
MessageProducer producer = session.createProducer(queue);
TextMessage msg = session.createTextMessage("xyz");
msg.setJMSCorrelationID("0123456789");//only for proof will use UUID or the like
producer.send(msg, Message.DEFAULT_DELIVERY_MODE, 0, 60000);

This causes a message to be sent with no JMS header. When checking the MQMD header the JMSCorrelationID has been translated correctly into the MQMD.CorrelID header value.

On the receiving side I have:
Code:

//omitted some code to setup the connection (oldschool jndi)
Connection connection = cf.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("TEST.REPLY");      
MessageConsumer consumer = session.createConsumer(queue, "JMSCorrelationID='0123456789'");
Object o = consumer.receive(1000);
if(o instanceof TextMessage) {
    TextMessage msg = (TextMessage) o;
    System.out.println("Message received: " + msg.getText());
    System.out.println("JMS ID: " + msg.getJMSMessageID());
    System.out.println("JMS CorrelID: " + msg.getJMSCorrelationID());
}

Even though i can see with RFHUtil (Browse) that a message is on the queue with the correct CorrelationID in the MQMD header (0123456789), the message isn't selected by the above code. If I omit the selector writing:
Code:

MessageConsumer consumer = session.createConsumer(queue);

The message is read and output in the console is:
Code:

Message received: xyz
JMS ID: ID:414d51204249583746465a54202020205ccdd65120377302
JMS CorrelID: ID:303132333435363738390000000000000000000000000000
Back to top
View user's profile Send private message
jborella
PostPosted: Mon Aug 05, 2013 2:20 am    Post subject: Reply with quote

Apprentice

Joined: 04 Jun 2009
Posts: 26

After two days of working and posting this, I found a solution. According to http://www-01.ibm.com/support/docview.wss?uid=swg21569646 it works if write:
Code:
         MessageConsumer consumer = session.createConsumer(queue, "JMSCorrelationID='ID:30313233343536373839'");

as the selector. Tested it, and it works.
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 » Problem with JMS MessageSelector and native MQ.
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.