Re: Problem with Java DSL filter
AHAAA!!! Stupid mistake. Thanks. -- View this message in context: http://camel.465427.n5.nabble.com/Problem-with-Java-DSL-filter-tp5713922p5713968.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Problem with Java DSL filter
On Mon, Jun 4, 2012 at 5:31 PM, addict wrote: > Yes Claus, when the routes execute for the first time tag will be null, > however any subsequent time tag will be having the string value assigned to > it (provided header has attribute tag which is having != null value, which > is the case with us). > > However on debugging i could see on each invocation tag was passed as null > even though SoP is printing the correct value. > Java is pass by value, in method call parameters. So you need to store the String in a Object holder of some sort if you want to be able to refer to it as it changes. Do some googling to read more about this. > -- > View this message in context: > http://camel.465427.n5.nabble.com/Problem-with-Java-DSL-filter-tp5713922p5713957.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen - FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen
Re: Problem with Java DSL filter
Yes Claus, when the routes execute for the first time tag will be null, however any subsequent time tag will be having the string value assigned to it (provided header has attribute tag which is having != null value, which is the case with us). However on debugging i could see on each invocation tag was passed as null even though SoP is printing the correct value. -- View this message in context: http://camel.465427.n5.nabble.com/Problem-with-Java-DSL-filter-tp5713922p5713957.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Problem with Java DSL filter
On Mon, Jun 4, 2012 at 7:33 AM, addict wrote: > public class Test extends RouteBuilder { > > > private volatile String tag = null; > @Override > public void configure() throws Exception { > from("http://url/a.csv";) > .filter(header("Tag").isNotNull()) > .filter(header("Tag").isNotEqualTo(tag)) > .process(new Processor() { > @Override > public void process(Exchange exchange) > throws Exception { > String s = > String.valueOf(exchange.getIn().getHeader( > "Tag")); > etag = new String(s); > System.out.println(tag); > } > }).to("file://c:/test/"); > } > > > > } > > > However the comparison always pick up the tag value as null. Can anybody > help > Do you mean this filter? > .filter(header("Tag").isNotEqualTo(tag)) Then its because the configure method is most likely executed before you have assigned a value to the tag value. > -- > View this message in context: > http://camel.465427.n5.nabble.com/Problem-with-Java-DSL-filter-tp5713919.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen - FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen