Messages
Messages are the objects that carry information between two
applications. They are constructed at one end, usually the producer side
of the messaging application. They are then consumed and deconstructed at
the other end, the consumer/subscriber side. Think of the message as an
object that carries business data, such a new Account
or Trade
information.
The publisher/producer creates these objects and publishes them to a
channel. A subscriber/consumer connected to the same channel then receives
those messages. The domain objects are then resurrected from these
messages, and business processing is carried out.
Dissecting a Message
The Message consists of two parts—the payload
and header
properties.
Imagine a greeting card arriving in your mailbox on your birthday.
The card inside the envelope may be called the
payload
. Payload
is the data or
the information that has to be processed by the interested parties. The
greeting card also has some additional information—the sender’s and
receiver’s addresses, first- or second-class delivery, and possibly
instructions such as “Handle with Care.” Such additional pieces of
information are header
properties.
The payload
and header
properties are represented as a Message
interface in Spring Integration, as
shown below:
public interface Message<T> { T getPayLoad(); MessageHeaders getHeaders(); }
Figure 2-1 depicts the
TradeMessage
composition.
Figure 2-1. Message Composition
From the above definition of a Message
, you can set any Plain Old Java ...
Get Just Spring Integration now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.