Spring Integration Tutorial (Part 7) – Service Activators

by | Sep 30, 2014

serviceactivator

As we near the end of this eight-part tutorial series on Spring Integration (SI), the topic of this seventh installment is on service activators.  The name of this SI message endpoint aptly defines what it does.  A service activator is an SI component that triggers (or activates) a Spring-managed service object or bean.  A service activator polls a message channel looking for messages.  On the arrival of a message, it calls the processing method of  the service bean (which is typically just a POJO).

The service’s processing method is passed the message or the payload of the message based on the parameter type to the processing method.  In fact, the service’s processing method can be passed no data.  In which case, the service activator is considered an event-style component that triggers processing just on the mere arrival of the message.  However, the processing method often uses the message data (its payload or header information) to perform work.  The service’s processing method may also optionally return a value or message.  The output, when returned, can be sent to an SI output channel.

service-activator

Watch the short presentation for more information on service activators below.

Once done with the video session, get some hands on experience through Lab 7.

Lab7-ServiceActivators

Lab 7 code files

Missed other parts of the tutorial series? Check them out using the links below.

Spring Integration Introduction

Spring Integration Tutorial (Part 1) – Understanding Channels

Spring Integration Tutorial (Part 2) – Adapters

Spring Integration Tutorial (Part 3) – Filters

Spring Integration Tutorial (Part 4) – Transformers

Spring Integration Tutorial (Part 5) – Routers

Spring Integration Tutorial (Part 6) – Enrichers

Spring Integration Tutorial (Part 7) – Service Activators

Spring Integration Tutorial (Part 8) – Gateways