Channels are used for routing messages to endpoints.
Channels do the routing and endpoints perform the operations.
Spring Integration (SI) provides numerous adapters for communication between different systems.
SI uses 3 types of components to construct its messaging architecture:
Endpoint > Channel (passes a Message) > Endpoint
A piece of information passed between 2 components.
Wraps any object used by SI. Object wrapped by message is called payload.
There may be also some headers that describe the message being sent (ex. ids, timestamps etc.).
Messages are very generic so they may deliver many types of payload:
- SOAP etc.
Object has no setter methods so the message is immutable.
Using channels to deliver messages between endpoints keeps the endpoints unaware of each other. So channels are the key to flexibility in SI.
Endpoints perform some operation when the message is received.
Consumer or producer simply describe the side of the channel an endpoint resides at.
Producers place messages on a channel to be delivered to a consumer that receives it.
Adapters and gateways are special types of endpoints used for connecting between 2 applications via some particular protocol – this usage of specific protocols is transparent for application using SI.
There may be also communication between a single application components and in that case messaging is used.
Channel types control how messages are received.
There are 2 primary types of channels:
Base channel interface is MessageChannel.
This interface defines channel that allows for messages to be delivered on request from a buffer by invoking the receive() method. So application runs asynchronously as it won’t wait for a response from the consumer.
Buffer is received from a producer.
Implementations of PollableChannel:
A FIFO channel. Even if the channel has multiple consumers, only one of them should receive any Message sent to that channel.
Messages polled based on their priority
Allow endpoints to request to be notified when a message is received.
The most basic type in SI. Implements SubscribableChannel. Allows for communication between 1 Producer and 1 Consumer.
Allows for multiple consumers of a message. One message is sent to all consumers. Suitable for event-type notifications.