In my last post I have showed you guys to send the control from camel to a java class but I did not show you how to manage the java class.
In my previous post, my camel is going to a class UIBkend.
Recap.
My code is:
<bean id="UIBkend" class="com.main.UIBkend">
</bean>
<camel:context>
<camel:route>
<camel:from uri="file:src/data?noop=true">
<camel:to uri="bean:UIBkend" />
</camel:context>
As you can see I did not mention any method name in the class. So the control must be going to some method. That method is called as the process. This method is coming from an Camel Interface called as Processor. When you implement this interface you are supposed to write logic to this method process, and this process takes Exchange as its input parameter.
Exchange is a camel message container. Basically what that means is, it is an object that holds all the camel information from the camel to the Java. If you are wondering if you could use this Exchange in someway to get some data from Camel to Java, then you are on right track. That will be my next post. Until then, my java code looks like.
public class UIBkend implements Processor{
@SuppressWarnings("unchecked")
@Override
public void process(Exchange exchange) throws Exception {
System.out.println("Saying hello from Java class.Camel routed me here.");
}
}
