Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In some scenarios, we would like to use a Message Router, but we need to have more flexibility and control over the routing rules that are being used. The drawback to a Message Router is that the rules are embedded statically and can’t be modified during execution. In situations where we need more control, we can utilize a Dynamic Router that allows the routing rules to be defined at startup time.

...

Beyond the standard input and output channels, the Dynamic Router will also use an additional control channel. At system start-up time, all of the possible recipients will transmit a message to the control channel that is connected to the Dynamic Router. This message is designed to signify their presence and define the conditions upon which they will accept a message.

...

The dynamic nature of this pattern will allow for a flexible, efficient, predictive routing model that eliminates the maintenance dependency of a message router.

Dynamic Router using XML DSL with Bean

Code Block
languagexml
<route>
    <from uri="direct:input"/>
    <dynamicRouter>
        <!-- use a method call on a bean as dynamic router -->
        <method beanType="com.bean.MyRoutingBean" method="findRoute"/>
    </dynamicRouter>
</route>