Skip to content

Instantly share code, notes, and snippets.

@mgpradeepa
Created October 10, 2016 06:58
Show Gist options
  • Save mgpradeepa/baef464d70e2ba42d28148d743e24a43 to your computer and use it in GitHub Desktop.
Save mgpradeepa/baef464d70e2ba42d28148d743e24a43 to your computer and use it in GitHub Desktop.
Spring Integration handbook from ref manual

Spring Integration framework.

Mainly focusses on the Enterprise Integration Application Framework. Design patterns are obtained and utilized as a integration solution from those.

One of the component is Message

Message is a generic wrapper for a java object combined with the metadata used by the framework. Payload & Headers are the key components of a message. Payload:- Can be of anything and any type data. Headers:-
Holds commonly required information like id, time_stamp, correlation_id and return address. Used to pass values - to and from connected ports For arbitrary key-value pairs Any specific properties for the channels

Basically this Messages are moved around with the technique of Pipe-and-Filters architectural style.

How: Using Message Channel.

Ways: Point-to-point or Publish/Subscribe

Pollable Channels are capable of buffering Messages with in queue. The advantage of this technique is it allows throttling of inbound message and there by preventing the overloading of the consumer.

Message Endpoints: Whole purpose of Message driven in the EAI through IOC is because the whole time would have been consumed in writing the producer and consumer as a custom need. Even building of the Message, invoke, send, receive of the message is also not required. Message channel takes care of all the above as a solution. Routing and Transformation of the message is taken care in this technique. Message endpoints can be thought of a MVC pattern. Just as a Controller handles HTTP requests, the Message Endpoint handles Messages. Just as Controllers are mapped to URL patterns, Message Endpoints are mapped to Message Channels. The goal is the same in both cases: isolate application code from the infrastructure

Listing the Message Endpoints

Transformer Filter Router Splitter Aggregator Service Activator Channel Adapter.

Transformer A Message Transformer is responsible for converting a Message’s content or structure and returning the modified Message. Most common type of transformer is one that converts the payload of the Message from one format to another (e.g. from XML Document to java.lang.String). Transformer may be used to add, remove, modify the messages header values.

Filter: A Message Filter determines whether a Message should be passed to an output channel at all. This simply requires a boolean test method that may check for a particular payload content type, a property value, the presence of a header, etc. If the Message is accepted, it is sent to the output channel, but if not it will be dropped (or for a more severe implementation, an Exception could be thrown). Message Filters are often used in conjunction with a Publish Subscribe channel, where multiple consumers may receive the same Message and use the filter to narrow down the set of Messages to be processed based on some criteria.

Router: A Message Router is responsible for deciding what channel or channels should receive the Message next (if any). The decision is based upon the Message’s content and/or metadata available in the Message Headers. 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. Message Router provides a proactive alternative to the reactive Message Filters used by multiple subscribers as described

Splitter: Type of Message Endpoint whose responsibility is to accept a Message from its input channel, split that Message into multiple Messages, and then send each of those to its output channel. Used for dividing a "composite" payload object into a group of Messages containing the sub-divided payloads.

Aggregator: Basically a mirror-image of the Splitter. Type of Message Endpoint that receives multiple Messages and combines them into a single Message. Aggregators are often downstream consumers in a pipeline that includes a Splitter 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. CorrelationStrategy & ReleaseStrategy are configurable setting for timeout if necessary.

Service Activator:

A generic endpoint for connecting a service instance to the messaging system. 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. The Service Activator invokes an operation on some service object to process the request Message, extracting the request Message’s payload and converting if necessary (if the method does not expect a Message-typed parameter).

Channel Adapter:

Connects a message Message Channel to some other system or transport. Channel adapters may be inbound or 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment