Friday, October 11, 2013

How to look inside a JMS ObjectMessage

http://docs.oracle.com/javaee/6/api/javax/jms/ObjectMessage.html
In OSB, all reporting messages are instances of com.bea.wli.reporting.jmsprovider.runtime.ReportMessage, and in the JMS message they are stored as an ObjectMessage. So, you won't be able to view their content in the WebLogic console, when they end up in the jmsResources module/dist_wli.reporting.jmsprovider_error.queue_auto queue.


Solution: export the message (one by one) into a jmsmessages.xml file using the WebLogic console Export tool (show messages).
in the resulting XML, the Object is expressed in base64 encoded format (text), in a xml tag mes:Object. Copy this text and put in a messagebody.xml (this can be automated, of course).

make sure these 2 jars are in WLST classpath (you can directly edit wlst.sh file):
/opt/oracle/fmw11_1_1_5/osb/lib/modules/com.bea.alsb.reporting.api.jar
/opt/oracle/fmw11_1_1_5/osb/lib/modules/com.bea.alsb.reporting.impl.jar


from org.apache.commons.codec.binary import Base64
f = open('messagebody.xml', 'r')
bytes = Base64.decodeBase64(f.read())

from java.io import ByteArrayInputStream
from java.io import ObjectInputStream
inputStream = ByteArrayInputStream(bytes)
objectStream = ObjectInputStream(inputStream)
obj = objectStream.readObject()

print obj.class
#it will print com.bea.wli.reporting.jmsprovider.runtime.ReportMessage


print obj.getXmlPayload()
print obj.getMetadata()



No comments: