Spring Integration Basics

Three components to the core Spring Framework:


messages,
message channels,
endpoints.
Messages

A message is a generic wrapper for any Java object combined with metadata used by Spring Integration to handle the object.
the Java object is the payload property, and the metadata is stored as a collection of message headers, which is in essence a Map with a String key and an Object value.
Headers


The org.springframework.integration.MessageHeaders object is a String/Object Map that typically maintains values for message housekeeping a rountine task . MessageHeaders are immutable and are usually created using the MessageBuilder API. There are a number of predefined entries (headers), including id, timestamp, correlation id, and priority. In addition, the headers can maintain values required by the adapter endpoints (e.g., the file name for the file adapter or the email address for the mail adapter).
Headers may be used any key/value pair required by the developer.


Payloads


The message payload can be any POJO. Spring Integration does not require message payloads to be in some sort of self-describing format. You can avail yourself of transformers to implement a canonical data model, as appropriate, but your hands aren’t tied if this isn’t appropriate for your application. Transformation support allows converting any payload into any type of format required by the message endpoint. This is in keeping with the noninvasive nature of Spring Integration.





Message Channels


A message channel is the component through which messages are moved. Message publishers send messages to the channel, and message consumers receive messages from the channel. The channel effectively decouples the producer and consumer. There are two types of messaging scenarios: point-topoint, in which a message is received only once, by a single consumer; and publish/subscribe, in which one or more consumers can attempt to receive a single message.


There are different ways to use a message channel, but generally your configuration will change according to whether you want messages on the channel to be published to you, or whether you want them queued.


Message Endpoints


A message endpoint is the abstraction layer between the application code and the messaging framework. An endpoint broadly defines all the types of components used in Spring Integration. It handles such tasks as producing and consuming messages, as well as interfacing with application code, external services, and applications. When data travels through a Spring Integration solution, it moves along channels from one endpoint to another. Data can come into the framework from external systems using a specific type of endpoint called an adapter. Spring Integration provides a number of adapters that interface with external applications and services; handling the interaction with the messaging infrastructure often only requires declarative configuration. Spring Integration provides a framework to build custom adapter endpoints in the (hopefully rare) event that the out-of-the-box adapters do not suffice.


The main endpoint types supported by Spring Integration are as follows:


• Transformer: Converts the message content or structure.
• Filter: Determines if the message should be passed to the message channel.
• Router: Can determine which channel to send a particular message based on its content.
• Splitter: Can break an incoming message into multiple messages and send them to the appropriate channel.
• Aggregator: Can combine multiple messages into one. An aggregator is more complex than a splitter often required to maintain state.
• Service activator: Is the interface between the message channel and a service instance, many times containing the application code for business logic.
• Channel adapter: Is used to connect the message channel to another system or transport.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

About This Site

Howdy! My name is Suersh Rohan and I am the developer and maintainer of this blog. It mainly consists of my thoughts and opinions on the technologies I learn,use and develop with.

Blog Archive

Powered by Blogger.

- Copyright © My Code Snapshots -Metrominimalist- Powered by Blogger - Designed by Suresh Rohan -