WAS v8.5 > Reference > Developer best practices

JMS formats - Stream

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


Stream body

We can retrieve the payload of a JMS Stream message as a Java list value (java.util.List). 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". For a JMS Stream message the value property might be accessed as a List value. The member functions of the List interface can be used to access the individual objects within the JMS Stream message instance. (Note the JMS standard places constraints on the kinds of objects that might be placed in a Stream message.)

We can access the data within the data graph with code such as this:

}SIMessage siMsg;
String format = siMessage.getFormat();
if (format.equals("JMS:stream")) {
  DataGraph graph = siMsg.getDataGraph();
  List payload = graph.getRootObject().getList("data/value");
  int streamLength = payload.size();
  if (streamLength > 0) {
    Object item1 = payload.get(0);
    // We can also access items directly, for example: (for the_same_ value)
    item1 = graph.getRootObject().get("data/value[1]");  
  }}


+

Search Tips   |   Advanced Search