One Star

How to use a cMessageFilter to filter by designated header values

Dear all.
I nearly tried the last three days to get the cMessageFilter component working in TESB Studio 5.1.1.
What I' d like to achieve is to build a route that routes the incoming message according to a value set within a special header. (e.g.: if (header value at key "type" is equals to "bla" then route message to jobA, otherwise to jobB)
As I stumbled over the documentation, all I found is to manually set the java code by using the choice element (see the following example)
...
.choice()
.when(header("type").isEqualTo("widget")).to("bean:widgetOrder")
.end();
..
But the TESB Studio doesnt let me set any of this code fragments.
It generates somtehing like this
...
.filter().header("isIVR")
...
As for I am using the TESB Studio, I wondered if it is possible to simply build this routing by "clicking your route" with the cMessageFilter component of TESB Studio 5.1.1.
But nevertheless I can't specify any further options than what type of routing EL I am using and the value to compare. There's no palce or filed to put more code into (see screen shots).
Maybe some of you did experience the same problem / behaviour. What's the next step I should take to solve my problem.
Thanks in advance.
Kind regards.
Alexander
3 REPLIES
One Star

Re: How to use a cMessageFilter to filter by designated header values

Hi Sasha,
as a 'when' condition try to use expressions like xpath( "/event/eventType = 'created'") or simple ("${heade.myHeader} = 'xxxx'") , see here: http://camel.apache.org/simple.html
Good luck
Gabriel
One Star

Re: How to use a cMessageFilter to filter by designated header values

Hi all.
The hint with the simple predicate languages (simple, ognl or mvel) solved my problem.
...
"${in.headers == 'IVR-Feedback'}"
...
The above expression filtered all messages where the header subject matches the value "IVR-Feedback".
Thanks for your support.
Regards
Alexander
Employee

Re: How to use a cMessageFilter to filter by designated header values

You may also want to take a look at the cMessageRouter. you mention in your original email that you are looking for something similar to the choice() DSL command. The choice Java DSL is used to implement the Content Based Router EIP, see http://camel.apache.org/content-based-router.html which is represented by the cMessageRouter in the tool palette. This will allow you to address multiple cases systematically much like an if-then-elseif clause. Note that when setting filter criteria using the cMessageRouter the condition is set on the line connecting the cMessageRouter to the different output paths.