Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Readers familiar with Java Message Service (JMS) will know that
the messages must be serialized and deserialized when sent or received,
respectively. The Payload Serializing transformer
transforms a POJO to a byte array. It is represented below by payload-serializing-transformer:
<int:payload-serializing-transformer input-channel="trades-in-channel" output-channel="trades-out-channel"> </int:payload-serializing-transformer>
When a SerializableTrade is
published onto the trades-in-channel,
the transformer picks and converts the payload to bytes. The
deserializing transformer is then used to read the bytes back to
SerializableTrade.
The deserializing transformer works in exactly the opposite manner
as its counterpart by deserializing the serialized payload to a POJO
message. It is represented by payload-deserializing-transformer and reads a
byte array. The following snippet demonstrates a deserializing
transformer printing out the toString() of SerializableTrade onto the console by picking
up the bytes from the trades-out-channel, the output channel of the
Serializing Transformer.