Standard router
Routes messages to channels based on the evaluation of a SpEL expression or Groovy script for each incoming message.
While all other routers have very specific uses, this component is extremely flexible. The downside is that this router can be harder to use because it involves scripting.
Maps values of the SpEL expression or Groovy script evaluation to channels.
If the value is not found in a mapping, the router will look for a channel which name matches the value.
Note that if the SpEL expression or Groovy script evaluation returns multiple values (a Collection
or comma-separated string), this router will route the message to multiple channels (this duplicates the message).
Allows you to define custom script variable bindings. This attribute isn't mutually exclusive with variables setting (see the basic tab) and all variables will be merged to one map.
The variables
payload
and headers
are always automatically available, even if you do not manually specify any variables. Since these two variables already give you access to all information in the message from your Groovy script, the main use-case for custom variables is probably to pass property values to the script.
All custom non-ref variables will be passed as a value of type String
to the Groovy script. If required, you can easily convert the data type using the Groovy as
keyword. For example: variableName as Integer
.
_id
The default channel where messages should be sent if the router didn't send the message to any of the normal output channels.
If no default output channel is provided and the router didn't send the message to any of the normal output channels a MessageDeliveryException
is thrown. If you would like to silently drop those messages instead, use the nullChannel as the default output channel.
A router might not be able to send a message to any of the normal output channels in the following cases:
resolving the routing criteria resulted in zero channels For example, when a header value router tries to route a message that doesn't contain the specified message header, or when the evaluation of the XPath expression by an XPath router produces no results.
resolving the routing criteria failed and 'resolution required' is disabled For example, when a header value router tries to route a message with a header value that is not specified in the mappings, or when all results of the evaluation of the XPath expression by an XPath router cannot be found in the mappings.
all send attempts failed and 'ignore send failures' is enabled For example, when every normal output channel connects to a down-stream filter that rejects the message using the throw exception on rejection option (the "selective consumer" pattern).
_id
The default channel where messages should be sent if the router didn't send the message to any of the normal output channels.
If no default output channel is provided and the router didn't send the message to any of the normal output channels a MessageDeliveryException
is thrown. If you would like to silently drop those messages instead, use the nullChannel as the default output channel.
A router might not be able to send a message to any of the normal output channels in the following cases:
resolving the routing criteria resulted in zero channels For example, when a header value router tries to route a message that doesn't contain the specified message header, or when the evaluation of the XPath expression by an XPath router produces no results.
resolving the routing criteria failed and 'resolution required' is disabled For example, when a header value router tries to route a message with a header value that is not specified in the mappings, or when all results of the evaluation of the XPath expression by an XPath router cannot be found in the mappings.
all send attempts failed and 'ignore send failures' is enabled For example, when every normal output channel connects to a down-stream filter that rejects the message using the throw exception on rejection option (the "selective consumer" pattern).
_id
Channel to consume the input messages from.
Required
_id
Channel to consume the input messages from.
Required