JMS Formats -- object

This topic contains reference information you can use to map from the body of a JMS object message to Service Data Objects (SDO) Version 1.

Object body

You can retrieve the payload of a JMS object message as a Java™ byte array (byte[]). First, you must retrieve a data graph representing the message from the SIMessage instance. As is common to all data graphs representing JMS messages, the root data object of the graph contains a property named "data", and that data object in turn contains a property named "value". In the case of a JMS object message the value property may be accessed as a Java byte array. The original Object instance which the payload represents may be reconstructed from the byte array.

Example

You can access the data within the data graph with code like this:
SIMessage siMsg;
String format = siMsg.getFormat();
if (format.equals("JMS:object")) {
  DataGraph graph = siMsg.getDataGraph();
  byte[] payload = graph.getRootObject().getBytes("data/value");
  if(payload != null) {
    // Need to deserialize to recover original object
    ObjectInputStream in = 
      new ObjectInputStream(new ByteArrayInputStream(payload));
    Object obj = in.readObject();
  }
}



Related reference
JMS formats
Reference topic    

Terms of Use | Feedback

Last updated: Aug 29, 2010 5:25:00 PM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=vela&product=was-base-dist&topic=rjy1135
File name: rjy1135.html