Hi The RouteBuilder configure method is only invoked once, to setup the Camel routes.
So if you want in the 2nd route to refer to a file name from a header, you can use the file/simple language for that. from("seda:myfile").pollEnrich("file:d:/a/?fileName=" + file).unmarshal(bindy).to("bean:validateFileInput?method=configure"); Should be from("seda:myfile").pollEnrich("file:d:/a/?fileName=${header.filename}") .unmarshal(bindy).to("bean:validateFileInput?method=configure"); eg notice the fileName parameter refers to a header with the key filename. Some links to check: http://camel.apache.org/simple.html http://camel.apache.org/file-language.html http://camel.apache.org/file2 On Mon, Sep 17, 2012 at 12:13 PM, Elezabeth <elezabeth.greg...@ibsplc.com> wrote: > Hi , > > I am new to Camel. > > My requirement is something like this . I have to read a csv file in a > folder when an HTTP url is invoked. > > This is fine. But I will get a url with a requestparameter called "fileName" > and now this is the name of that csv file which i have to read. > > Eg; > > if my url is*/ http://localhost/test?filename=sample-2.csv/* , then I have > to read *sample-2.csv *from that folder. > I tried doing this in either way - using XML and using Java code. > > This is how I configured the route > > public class OagBuilder extends RouteBuilder { > > CamelContext camelContext = new DefaultCamelContext(); > DataFormat bindy = new BindyCsvDataFormat( > "jp.co.airlink.gavss.adapter.eai.oag.job"); > String file = null; > > public void add(Exchange exchnage){ > > file= (String) exchnage.getIn().getHeader("filename"); > } > > @Override > public void configure() throws Exception { > > > from("jetty:http://localhost:8080/test").inOnly("seda:myfile").to("bean:oagProcessor?method=add"); > //file= Exchange.HTTP_QUERY.split("filename"); > //System.out.println("fileis " + file) ; > from("seda:myfile").pollEnrich("file:d:/a/?fileName=" + > file).unmarshal(bindy).to("bean:validateFileInput?method=configure"); > } > > } > > I am not getting the value of the variable "file" in the second route. > > Can anyone help me . > > > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Dynamically-variable-in-Camel-tp5719462.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