Book Image

Spring Integration Essentials

By : CHANDAN K PANDEY
Book Image

Spring Integration Essentials

By: CHANDAN K PANDEY

Overview of this book

This book is intended for developers who are either already involved with enterprise integration or planning to venture into the domain. Basic knowledge of Java and Spring is expected. For newer users, this book can be used to understand an integration scenario, what the challenges are, and how Spring Integration can be used to solve it. Prior experience of Spring Integration is not expected as this book will walk you through all the code examples.
Table of Contents (12 chapters)
11
Index

Service activators

Service activators are one of the simplest and most useful endpoints—a plain java class whose methods can be invoked on the messages received on a channel. Service activators can either terminate the message processing or pass it on to the next channel for further processing. Let's have a look at the following example. We would like to do some validation or business logic before passing the message on to the next channel. We can define a Java class and annotate it as follows:

@MessageEndpoint
public class PrintFeed {
  @ServiceActivator
  public String upperCase(String input) {
    //Do some business processing before passing the message
    return "Processed Message";
  }
}

In our XML, we can attach the class to a channel so that it processes each and every message on it:

<int:service-activator input-channel="printFeedChannel" ref="printFeed" output-channel="printFeedChannel" />

Let's quickly go through the...