O'Reilly logo

Just Spring Integration by Madhusudhan Konda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Routers

One of the flow requirements is to send the messages to one or more channels based on certain criteria. A router component can be used to distribute the messages to multiple destinations. For example, the requirement is that all new Trades should be sent to new-trades-in-channel while all amended Trades are sent to amended-trades-in-channel. The Router component will take care of this task. The router picks up the message from a channel and redelivers (routes) it to the relevant channel based on payload or headers content.

There is a difference between the filters and routers. While Filter decides whether or not the message is to be sent based on a simple Boolean test, Router forwards the message to one or more channels based on content. There are only two options for a message that’s being passed through a Filter—forwarded or discarded. If a filter is used, a message may or may not appear in an output channel, whereas if a router is used, a single message can be sent to one or more channels.

The framework provides a couple of built-in routers: PayloadTypeRouter, based on payload content, or HeaderValueRouter, based on header values.

PayloadTypeRouter

The PayloadTypeRouter determines the routing of messages to different channels based on the type of the payload. The router endpoint attached to an incoming channel will evaluate the type and accordingly distribute (route) the messages to other channels expecting that particular type. The payload-type-router element is used to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required