@Router marks a Spring Integration bean as a router: it examines a message and directs it to one of several channels according to routing criteria. section 10.2 section 10.2.4
A router can be implemented in several practical ways:
- Declare an AbstractMessageRouter bean with @Router and return the target channel for each message. section 10.2.4
- Route even and odd integers from numberChannel to evenChannel or oddChannel by inspecting the payload. section 10.2.4
- Use a PayloadTypeRouter after a splitter to send BillingInfo and List payloads to different channels. section 10.2.5
- In Java DSL, call route() and map returned values such as EVEN and ODD to separate subflows. section 10.2.4
Even-and-odd message routing
An @Router bean receives messages from numberChannel, reads the integer payload, and returns evenChannel for even numbers or oddChannel for odd numbers. Each channel can then continue with its own processing flow.
