concept content - base router in category camel

appears as: content-based router, The content-based router
Camel in Action

This is an excerpt from Manning's book Camel in Action.

2.6.1 Using a content-based router

As the name indicates, a content-based router (CBR) is a message router that routes a message to a destination based on its content. The content could be a message header, the payload data type, or part of the payload itself—pretty much anything in the message exchange.

Listing 4.11  The content-based router uses the bean as a predicate in XML
<bean id="customerService" class="camelinaction.CustomerService"/>     #1 <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="file://target/order"/> <choice> <when> <method ref="customerService" method="isGold"/>     #2 <to uri="mock:queue:gold"/> </when> <when> <method ref="customerService" method="isSilver"/>     #3 <to uri="mock:queue:silver"/> </when> <otherwise> <to uri="mock:queue:regular"/> </otherwise> </choice> </route> </camelContext> #1 Declares the bean so you can refer to the bean in the upcoming route #2 The method call predicate that invokes the isGold method on the bean #3 The method call predicate that invokes the isSilver method on the bean