Argh! So simple :D Thanks, Ben, worked perfectly.
On 23 April 2011 15:46, Ben O'Day <ben.o...@initekconsulting.com> wrote: > put the <to> before the closing </filter> tag... > > _______________ > Ben O'Day > > On Apr 23, 2011, at 5:39 AM, Mark Doyle <markjohndo...@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! >