1 what is routing
Input and output queues are unaware of the conditions in between them. The condi-tional logic is decoupled from the message consumer and producer.
2 java dsl
A typical JAVA DSL is written like this: from..process..filter...bean...log...to...
The from method tells Camel to consume messages from an FTP endpoint( fror example), and the to method instructs Camel to send messages to a JMS endpoint(example).
3 using camel and spring
step 1 In maven ,camel-spring artifactId firstly needs to be imported.
step 2 application.xml needs to add the following piece of code:
<camelContext xmlns="http://camel.apache.org/schema/spring">
<packageScan>
<package>camelinaction.routes</package>
<excludes>**.*Test*</excludes>
<includes>**.*</includes>
</packageScan>
</camelContext>
step 3 self-designed route extends SpringRouteBuilder
type of route
4 Using a content-based router
from("jms:incomingOrders")
.choice()
.when(header("CamelFileName").endsWith(".xml"))
.to("jms:xmlOrders")
.when(header("CamelFileName").regex("^.*(csv|csl)$"))
.to("jms:csvOrders")
.otherwise()
.to("jms:badOrders")
.end()
.to("jms:continuedProcessing");
5 Using message filters
the source directory has two xml files and filter method filter them according to the xpath rules
6 Using multicasting
under this route type, When the list of destinations is known ahead of time and is static, you can add an element to the route that will consume messages from a source endpoint and then send the message out to a list of definite destinations. parallelProcessing is used here for setting up the multicast to distribute messages to the destinations in parallel.
By default, the multicast will continue sending messages to destinations even if one fails. In your application, though, you may consider the whole process as failed if one destination fails. What do you do in this case? answer : use the stopOnException() right after the multicast()
7 Using recipient lists
the destinations are determined by header("recipients") which must be iterable and processed in the processor, which means the destinations are dynamic.
from what i 've experienced in working simple() can also be used instead of header().
8 Using the wireTap method( for debug in production environment)
By using the wireTap method in the Java DSL , you can send a copy of the exchange to a secondary destination without affecting the behavior of the rest of the route: