The Spring Integration Message
is a generic container for data. Any object can
be provided as the payload, and each Message
also includes headers containing
user-extensible properties as key-value pairs.
Here is the definition of the Message
interface:
public interface Message<T> { T getPayload(); MessageHeaders getHeaders(); }
The Message
is obviously a very important part of the API. By encapsulating the
data in a generic wrapper, the messaging system can pass it around without any knowledge of the data's type. As
an application evolves to support new types, or when the types themselves are modified and/or extended, the
messaging system will not be affected by such changes. On the other hand, when some component in the messaging
system does require access to information about the Message
,
such metadata can typically be stored to and retrieved from the metadata in the Message Headers.