How to create a camel route that references a specific Java method? -


i want write camel route reads xml files in specific directory, calls process java method of class implements processor , print result screen.

for example java class named scriptprocessor, , has process method:

public class scriptprocessor implements processor{      final script script ;       public scriptprocessor(script script){         this.script = script;     }       @override     public void process(exchange exchange) throws exception {        //do ...      }  } 

so, have camel context route this:

   <camelcontext xmlns="http://camel.apache.org/schema/spring">       <route>         <from uri="file:?noop=true"/>         <to uri="mock:result"/>       </route>     </camelcontext> 

i suppose xml files in same directory of file camel context definition ("from" tag), , use mock element specify destination of route. don't know how call process method of scriptprocessor class inwards camel route. it's necessary "process" tag or similar? can me?

you can use processor way:

<bean id="scriptprocessor" class="com.my.app.scriptprocessor"/>  <camelcontext xmlns="http://camel.apache.org/schema/spring">   <route>     <from uri="file:?noop=true"/>     <process ref="scriptprocessor" />     <to uri="mock:result"/>   </route> </camelcontext> 

or use camel bean integration:

public class somebean {      public void somemethod(exchange exchange) throws exception {         //do     } } 

camel context:

<camelcontext xmlns="http://camel.apache.org/schema/spring">   <route>     <from uri="file:?noop=true"/>     <bean ref="somebean" method="somemethod"/>     <to uri="mock:result"/>   </route> </camelcontext> 

for more details please see http://camel.apache.org/bean-language.html


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -