What is the difference for accessing the processor using the <process ref = "bean id"> tag or using <to uri = "bean: id">?
2 answers
If your bean is an implementation org.apache.camel.Processor, then there is no practical difference. However, using bean bindings gives you more flexibility. Among other things bean
- no need to implement
org.apache.camel.Processor - can offer any number of methods to call
- with arbitrary method signature
- , org.apache.camel.Body org.apache.camel.Header
beans bean .
+2
, .
java DSL .
from("direct:demo").process(new Processor() {
public void process(Exchange exchange) throws Exception {
// some stuff
}
}).to("mock:demoEnd");
:
<route id="sample">
<from uri="direct:demo"/>
<process ref="firstProcessor"/>
<to uri="mock:otherRoute"/>
<process ref="secondProcessor"/>
<to uri="mock:endTest"/>
</route>
Vs
<route id="sample">
<from uri="direct:demo"/>
<to uri="bean:firstProcessor"/>
<to uri="mock:otherRoute"/>
<to uri="bean:secondProcessor"/>
<to uri="mock:endTest"/>
</route>
+1