Spring Integration notes (in progress)

Introduction

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:

  1. Message
  2. Channel
  3. Endpoint

Endpoint > Channel (passes a Message) > Endpoint

Message

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:

  • String
  • Object
  • XML
  • JSON
  • SOAP etc.

Object has no setter methods so the message is immutable.

Channels 

Using channels to deliver messages between endpoints keeps the endpoints unaware of each other. So channels are the key to flexibility in SI.

Endpoints

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.

Channels

Channel types control how messages are received. 

There are 2 primary types of channels:

  1. PollableChannel
  2. SubscribableChannel

Base channel interface is MessageChannel.

PollableChannel

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:

QueueChannel

A FIFO channel. Even if the channel has multiple consumers, only one of them should receive any Message sent to that channel.

PriorityQueueChannel

Messages polled based on their priority

SubscribableChannel

Allow endpoints to request to be notified when a message is received.

DirectChannel

The most basic type in SI. Implements SubscribableChannel. Allows for communication between 1 Producer and 1 Consumer.

PublishSubscribeChannel

Allows for multiple consumers of a message. One message is sent to all consumers. Suitable for event-type notifications.

LEAVE A REPLY

Please enter your comment!
Please enter your name here