Reputation: 1896
In several of my camel routes, I need to access a field of an object, process it, and use it for something.
For example: Say I have an object of
class myClass {
int fieldA;
String fieldB;
}
which is used as an exchange header, say on myOldHeader
. In my route definition, I want to access fieldA
from this header, process it with, a function of some bean, say String myIntTransform(int)
, and place the result into some other header. That is, I would like to have an element in my route definition similar to the following (pseudocode):
from(direct:input)
.setHeader("myNewHeader").method("MyBean", "myIntTransform").on(header("myOldHeader").field("fieldA")
.to(direct:output)
I know that Camel comes with a zoo of expression languages and DSLs for all sorts of tasks. But so far, I haven't found a convenient way to accomplish the above without having to put specific annotations (like @Header
) on "myBean", which would create a tight coupling of beans I am trying to avoid.
Upvotes: 2
Views: 185