Red Hat Training

A Red Hat training course is available for JBoss Enterprise SOA Platform

4.2.21. Extensions to the Message Body

Extensions Types

org.jboss.soa.esb.message.body.content.TextBody
the content of the Body is an arbitrary string, and can be manipulated via the getText and setText methods.
org.jboss.soa.esb.message.body.content.ObjectBody
the content of the Body is a serialized object, and can be manipulated via the getObject and setObject methods.
org.jboss.soa.esb.message.body.content.MapBody
the content of the Body is a Map(String, Serialized), and can be manipulated via the setMap and other methods.
org.jboss.soa.esb.message.body.content.BytesBody
the content of the body is a byte stream that contains arbitrary Java data-types. It can be manipulated using the various setter and getter methods for the data-types. Once created, the BytesMessage should be placed into either a read-only or write-only mode, depending upon how it needs to be manipulated. It is possible to change between these modes (using readMode and writeMode), but each time the mode is changed the buffer pointer will be reset. In order to ensure that all of the updates have been pushed into the body, it is necessary to call flush when finished.
You can create messages that have body implementations based on one of these specific interfaces through the XMLMessageFactory or SerializedMessageFactory classes.
There is a create method associated with each of the various body types. An example is createTextBody. Use this to create and initialize a message of that specific type. Once created, manipulate the message directly by editing the raw body or by using its interface's methods. The body's structure is maintained even after transmission so that it can be manipulated by the message recipient using the methods of the interface that created it.
The XMLMessageFactory and SerializedMessageFactory are more convenient ways in which to work with Messages than the MessageFactory and associated classes.

Note

These extensions to the base body interface are provided in a complimentary manner to the original body. As such they can be used in conjunction with existing clients and services. Message consumers can remain unaware of these new types if necessary because the underlying data structure within the message remains unchanged. It is important to realise that these extensions do not store their data in the default location. Data should be retrieved using the corresponding getters on the extension instance.