Quantcast
Channel: Java mon amour
Viewing all articles
Browse latest Browse all 1124

OSB binary JMS messages

$
0
0
If someone sets the message type to "binary" for a JMS Business Service, this will generate BytesMessage rather than TextMessage. You might have performance reasons to do that. But it's a pain, because in the WebLogic console these messages will not be very readable.
If you want to process those messages with some Java utility, you can still get the content of the message this way:

Enumeration msgs = queueBrowser.getEnumeration();
while (msgs.hasMoreElements()) {
Message tempMsg = (Message)msgs.nextElement();
String msgContent = "";
if (tempMsg instanceof BytesMessage) {
weblogic.jms.common.BytesMessageImpl bm = (weblogic.jms.common.BytesMessageImpl)tempMsg;
msgContent = new String(bm.getBodyBytes());
}
if (tempMsg instanceof TextMessage) {
msgContent = ((TextMessage)tempMsg).getText();
}

}

the method getBodyBytes() is not part of the BytesMessage interface, but it's very convenient...
I guess that the message body COULD be compressed, in that case you are screwed, you might try decompressMessageBody() before reading the body, not sure...

Viewing all articles
Browse latest Browse all 1124

Trending Articles