|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How to get JMSMessage for MQMessage(format=MQHEPCF) |
« View previous topic :: View next topic » |
Author |
Message
|
amitgoelamit |
Posted: Tue Sep 23, 2008 6:13 am Post subject: How to get JMSMessage for MQMessage(format=MQHEPCF) |
|
|
Novice
Joined: 19 Jul 2008 Posts: 20
|
We are using JMS asynchronous onMessage(Message msg) to read the activity report message (FORMAT = MQHEPCF) from SYSTEM.ADMIN.ACTIVITY.QUEUE.
The Message is received and is instanceof BytesMessage but, it returns 0 size body length (int len = bmsg.getBodyLength). That means the message has no data.
We further tested by reading the activity report message directly from SYSTEM.ADMIN.ACTIVITY.QUEUE using MQ Java API MQMessage, set the FORMAT to ADMIN, and sent the message back to SYSTEM.ADMIN.ACTIVITY.QUEUE.
Now we tried the same JMS program again and this time got the data.
We concluded that for Message FORMAT = MQHEPCF, MQJMSTransformNode (http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/ac24872_.htm
) doesn’t transform MQMessage to JMS Message.
If our conclusion is correct then please let us know at the earliest the alternative approach else where did we go wrong on using JMS asynchronous connection or on receiving messages.
We are majorly seeking a listener rather than polling on the SYSTEM.ADMIN.ACTIVITY.QUEUE which gets the Message when ever one is available.
It is a show stopper for us and require guidance.
Sample program to process JMS Message:
Code: |
public void process(Message msg){
//if message is activity report message
if(msg instanceof StreamMessage){
System.out.println("Stream");
StreamMessage smsg = (StreamMessage)msg;
}
if(msg instanceof BytesMessage){
BytesMessage bmsg = (BytesMessage)msg;
byte bytes[];
try {
Enumeration propsenum = msg.getPropertyNames();
while(propsenum.hasMoreElements())
System.out.println(propsenum.nextElement());
int len = (int) bmsg.getBodyLength();
bytes = new byte[(int) bmsg.getBodyLength()];
bmsg.readBytes(bytes);
Date dateTime = new Date(bmsg.getJMSTimestamp());
System.out.println(dateTime);
String data = new String(bytes);
System.out.println(data);
} catch (JMSException jmse) {
logger.error(TraceConstants.PROCESS_NAME+"error in parsing activity report message. Will continue to next activity report message", jmse);
}
}
}
|
|
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Sep 23, 2008 8:52 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Seems to me something is fishy there. Don't know what happens if you retrieve the message length multiple times.
Quote: |
int len = (int) bmsg.getBodyLength();
bytes = new byte[(int) bmsg.getBodyLength()];
bmsg.readBytes(bytes); |
I would just have used
bytes = new byte[len];
as you just retrieved len the line before. Did you check for len > 0?
Note from the manual:
Quote: |
The value returned is the entire length of the message body, regardless of where the pointer for reading the message is currently located. |
Could it be that your default read cursor is already at the end of the message? Have you tried calling msg.reset() before calling msg.readBytes(myarray)?
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
amitgoelamit |
Posted: Sat Oct 18, 2008 12:42 am Post subject: |
|
|
Novice
Joined: 19 Jul 2008 Posts: 20
|
As per IBM support ...
The support for converting MQMessage to JMSMessage for 'MQHEPCF' FORMAT type is not implemented as per IBM MQ JMS design :|
So what effectively happens is that the JMS to MQ node converter discards the payload for 'MQHEPCF' FORMAT type message.
This one can test by taking the 'MQHEPCF' FORMAT message via MQ for Java APIs and resetting the FORMAT of the message from 'MQHEPCF' to 'MQADMIN' or 'STRING' FORMAT.
Then run the JMS program and you can see the payload. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Oct 18, 2008 8:05 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
OK,
So you can trigger the SYSTEM.ADMIN.ACTIVITY.QUEUE with a base Java program that does the work or writes it to an app queue with the new format, where you have an MDB listening...
Bearing in mind that we are not going the exit route changing the message format on the fly.  _________________ MQ & Broker admin |
|
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
|
|
|
|