Book Image

Spring Integration Essentials

By : CHANDAN K PANDEY
Book Image

Spring Integration Essentials

By: CHANDAN K PANDEY

Overview of this book

Table of Contents (18 chapters)
Spring Integration Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
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 elements used in the preceding declaration:

  • @MessageEndpoint...