Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

MQ and JMS and message id

843830Aug 1 2006 — edited Aug 1 2006
Hi,

I have a legacy application written in C++ which utilize MQ API as its messaging interface.
This legacy application filter message based on messageId, let's say, it will only pick up message with messageId = "java" from particular queue.

Now this is the problem, using JMS API, I cannot set the message id directly in a message. According to JMS spec and MQ implementation docs:

1. From http://publib.boulder.ibm.com/iseries/v5r1/ic2924/books/c3454563.pdf page 174 JMSMessageID from MQMD MessageID: Any value set into the JMSMessageId field prior to a send() is overwritten.

2. From http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/com.ibm.mq.csqzaw.doc/csqzaw1484.htm
setJMSMessageID. Sets the message ID. Any value set using this method is ignored when the message is sent, but this method can be used to change the value in a received message.

The value set into JMSMessageID prior send() or publish() will be ignored.

Is there any work around to force setting Message Id using MQ JMS?

I have tried, if I use the JMS API like this:
     textMessage = m_queueSession.createTextMessage();
     textMessage.setText(message);
     textMessage.setJMSMessageID("java");
the message is never picked up.

But when I use Java MQ API like this:
     MQMessage msg = new MQMessage();
     msg.writeString(text);

     MQPutMessageOptions pmo = new MQPutMessageOptions();
     String messageId = "java";
     msg.messageId = messageId.getBytes();
and the message get picked up.

But I don't like the idea to use MQ API, it creates interoperability and maintenance issues. Other modules within my application uses JMS API. In fact, I'm use Spring for JMS configuration and handling, and Spring support JMS neatly. So, MQ API is not likely to be a good option in this case.

1. Any workaround to set message id using MQ JMS ?
2. Any other idea?

Thanks in advance!

rgds,

Alex
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 29 2006
Added on Aug 1 2006
4 comments
807 views