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

Routers


Routers are components that pick messages from a channel and, depending on a set of pre-defined criteria, deliver them to different channels. Routers never change the message—they only route/reroute messages to the next destination. Spring Integration provides the following built-in routers:

  • Payload-type router

  • Header value router

  • Recipient list router

  • XPath router (part of the XML module)

  • Error message exception-type router

Payload-type router

As the name suggests, this router will route the message based on the payload data type. For example, we can have a dedicated channel for string, another one for integer and yet another channel for a user-defined payload type. A simple code snippet from our feeds example is as follows:

<int:payload-type-router input-channel="transformedChannel">
  <int:mapping type="com.cpandey.siexample.pojo.SoFeed" channel="jdbcChannel" />
  <int:mapping type="java.lang.String" channel="jmsChannel" />
  <int:mapping type="org.springframework...