Network Deployment (Distributed operating systems), v8.0 > Reference > Developer best practices


JMS Formats - object

Your program can retrieve the payload of a JMS object message by mapping the body of the message to an SDO data graph representing the message.


Object body

We can retrieve the payload of a JMS object message as a Java byte array (byte[]). First, 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". For a JMS object message the value property might be accessed as a Java byte array. The original Object instance that the payload represents might be reconstructed from the byte array.


Example

We can access the data within the data graph with code such as 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();
  }
}

+

Search Tips   |   Advanced Search