Description :
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.
With Out WireTap Method:
// add our route to the CamelContext
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
// load file orders from src/data into the JMS queue
from("file:/venkatjavasource/camel/from?noop=false").to("jms:incomingOrders");
// content-based router
from("jms:incomingOrders")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
System.out.println("Received order: " + exchange.getIn().getBody(String.class));
}
})
.choice()
.when(header("CamelFileName").endsWith(".xml"))
.to("jms:xmlOrders")
.when(header("CamelFileName").regex("^.*(csv|csl)$"))
.to("jms:csvOrders")
.otherwise()
.to("jms:badOrders");
}
});
With WireTap Method:
With wireTap, we can simplify the code, and send all the processed orders to secondary
destination. say jms:orderAudit
// add our route to the CamelContext
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
// load file orders from src/data into the JMS queue
from("file:/venkatjavasource/camel/from?noop=false").to("jms:incomingOrders");
// content-based router
from("jms:incomingOrders")
.wireTap("jms:orderAudit")
.choice()
.when(header("CamelFileName").endsWith(".xml"))
.to("jms:xmlOrders")
.when(header("CamelFileName").regex("^.*(csv|csl)$"))
.to("jms:csvOrders")
.otherwise()
.to("jms:badOrders");
}
});
*** Venkat – Happy leaning ****