A message transformer is responsible for converting a message’s content or structure and returning the modified message. Probably the most common type of transformer is one that converts the payload of the message from one format to another (such as from XML to java.lang.String). Similarly, a transformer can add, remove, or modify the message’s header values.
Message filters are used to decide whether a Message should be passed along or dropped based on some criteria, such as a message header value or message content itself. Therefore, a message filter is similar to a router, except that, for each message received from the filter’s input channel, that same message may or may not be sent to the filter’s output channel.
publicinterfaceMessageSelector{
booleanaccept(Message<?> message);
}
MessageFilter filter = new MessageFilter(someSelector);
Message Router
A message router is responsible for deciding what channel or channels (if any) should receive the message next. A message router is often used as a dynamic alternative to a statically configured output channel on a service activator or other endpoint capable of sending reply messages.
PayloadTypeRouter
HeaderValueRouter
RecipientListRouter
Splitter
A splitter is another type of message endpoint whose responsibility is to accept a message from its input channel, split that message into multiple messages, and send each of those to its output channel. This is typically used for dividing a “composite” payload object into a group of messages containing the subdivided payloads.
Aggregator
The aggregator is a type of message endpoint that receives multiple messages and combines them into a single message. Technically, the aggregator is more complex than a splitter, because it is required to maintain state (the messages to be aggregated), to decide when the complete group of messages is available, and to timeout if necessary. Furthermore, in case of a timeout, the aggregator needs to know whether to send the partial results, discard them, or send them to a separate channel. Spring Integration provides a CorrelationStrategy, a ReleaseStrategy, and configurable settings for timeout, whether to send partial results upon timeout, and a discard channel.
Service Activator
A Service Activator is a generic endpoint for connecting a service instance to the messaging system. The input message channel must be configured, and, if the service method to be invoked is capable of returning a value, an output message Channel may also be provided.
Channel Adapter
A channel adapter is an endpoint that connects a message channel to some other system or transport. Channel adapters may be either inbound or outbound. Typically, the channel adapter does some mapping between the message and whatever object or resource is received from or sent to the other system (file, HTTP Request, JMS message, and others). Depending on the transport, the channel adapter may also populate or extract message header values. Spring Integration provides a number of channel adapters, which are described in upcoming chapters.
Inbound & Outbound
An inbound channel adapter endpoint connects a source system to a MessageChannel
An outbound channel adapter endpoint connects a MessageChannel to a target system.
The pattern arose as the most flexible way to integrate multiple disparate systems in a way that:
Almost completely decouples the systems involved in the integration
Allows participant systems in the integration to be completely agnostic of each others underlying protocols, formatting, or other implementation details
Encourages the development and reuse of components involved in the integration