camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Problem dynamically filtering a route using a bean via camel:method
Date Sat, 23 Apr 2011 15:26:20 GMT
We might wanna add a check in the filter eip that it has child
processors. So it would fail starting in this case. We do have that
for some of the other eips

On Saturday, April 23, 2011, Mark Doyle <markjohndoyle@googlemail.com> wrote:
> Argh! So simple :D
>
> Thanks, Ben, worked perfectly.
>
> On 23 April 2011 15:46, Ben O'Day <ben.oday@initekconsulting.com> wrote:
>> put the <to> before the closing </filter> tag...
>>
>> _______________
>> Ben O'Day
>>
>> On Apr 23, 2011, at 5:39 AM, Mark Doyle <markjohndoyle@googlemail.com> wrote:
>>
>>> Hi all,
>>> I'm having a little trouble with a dynamically filtered route.
>>> My route is defined in Spring as follows:
>>> <!--The came route used to retrieve packets for the gui. Can be altered -->
>>>     <camelContext id="camelContextBean"
>>> xmlns="http://camel.apache.org/schema/spring">
>>>         <route id="fromJmsProcessedParametersOut" autoStartup="false">
>>>             <from uri="jms:topic:processedParametersOut" />
>>>                 <camel:filter>
>>>                     <camel:method bean="parameterFilterer"></camel:method>
>>>                 </camel:filter>
>>>             <to uri="bean:camelParameterProvider?method=parameterIn"
/>
>>>         </route>
>>>     </camelContext>
>>>
>>> The filter bean has a method called matches which is being called by
>>> camel. The method is as follows:
>>>
>>> public final boolean matches(@Header("ParameterName") final String
>>> headerParameterName) {
>>>    boolean result = false;
>>>
>>>    if (this.parameterNames == null) {
>>>        result = true;
>>>    }
>>>    else if (parameterNames.size() > 0) {
>>>        for (String parameterName : parameterNames) {
>>>            System.out.println(parameterName + " : " + headerParameterName);
>>>            // if the filter name matches the parameter in this message
header
>>>            if (StringUtils.equals(parameterName, headerParameterName))
{
>>>                System.out.println("Filter match for " + parameterName
>>> + " : " + headerParameterName);
>>>                result = true;
>>>            }
>>>        }
>>>    }
>>>
>>>    System.out.println("Returning " + result);
>>>    return result;
>>> }
>>>
>>>
>>> Now, according to the System outs the returns are correct. If I change
>>> the parameterNames Set at runtime the filter processes the list and
>>> returns the correct true or false flag. The problem is that Camel
>>> still routes every message.
>>>
>>> Can anybody see any reason why this design will not work or whether
>>> I've missed something in implementing it.
>>>
>>> Thanks!
>>
>

-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
CamelOne 2011: http://fusesource.com/camelone2011/
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message