You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Abhinay <ab...@gmail.com> on 2016/08/12 04:34:19 UTC

Global level Configuration for multiple routes with same file endpoints

Hi Team,

I have a requirement where I integrated Camel with Spring Boot, We have
multiple routes where each route process file with respective Processor
class and file will moves to preferred location, here my code like this,

@Component
public class OCCAccSumRptRouter extends RouteBuilder {
	@Value("${file.fileLocation}")
	private String fileLocation;  //value will be /interfaces/data/
	
	@Value("${file.fileNamePattern}")
	private String fileNamePattern; //File pattern will different for each
route as each file processing logic different.
	
	public void configure() throws Exception {	
		String file =
"file:"+fileLocation+"?include="+fileNamePattern+"&readLock=rename";	
		from(file).doTry().bean(MyProcessor.class,"processMessage(${body},
${header.CamelFileNameOnly})").to("file:"+fileLocation+"/.done?FileName=${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}").doCatch(Exception.class).to("file:"+fileLocation+"/.failed?FileName=${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}").end(); 
	}
}

Above route will process the file to MyProcessor class after on basis of
success file will moves to '.done' folder or if process fails file need to
move '.failed' and renamed with current time stamp.

So here my requirement is as right now we have 20+ routes and will get
3times of current number, defining file end point (to("destination")) in
each route is good, could you please help me out want to configure in global
level so that I don't need mention in each routes as file end point is
common to all routes is same .

Thanks,
Abhinay K



--
View this message in context: http://camel.465427.n5.nabble.com/Global-level-Configuration-for-multiple-routes-with-same-file-endpoints-tp5786341.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Global level Configuration for multiple routes with same file endpoints

Posted by Vitalii Tymchyshyn <vi...@tym.im>.
You can always use direct (http://camel.apache.org/direct.html) to extract
common parts of routes.

Нд, 14 серп. 2016 12:30 користувач Abhinay <ab...@gmail.com> пише:

> Hi Team,
>
> I have a requirement where I integrated Camel with Spring Boot, We have
> multiple routes where each route process file with respective Processor
> class and file will moves to preferred location, here my code like this,
>
> @Component
> public class OCCAccSumRptRouter extends RouteBuilder {
>         @Value("${file.fileLocation}")
>         private String fileLocation;  //value will be /interfaces/data/
>
>         @Value("${file.fileNamePattern}")
>         private String fileNamePattern; //File pattern will different for
> each
> route as each file processing logic different.
>
>         public void configure() throws Exception {
>                 String file =
> "file:"+fileLocation+"?include="+fileNamePattern+"&readLock=rename";
>
> from(file).doTry().bean(MyProcessor.class,"processMessage(${body},
>
> ${header.CamelFileNameOnly})").to("file:"+fileLocation+"/.done?FileName=${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}").doCatch(Exception.class).to("file:"+fileLocation+"/.failed?FileName=${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}").end();
>         }
> }
>
> Above route will process the file to MyProcessor class after on basis of
> success file will moves to '.done' folder or if process fails file need to
> move '.failed' and renamed with current time stamp.
>
> So here my requirement is as right now we have 20+ routes and will get
> 3times of current number, defining file end point (to("destination")) in
> each route is good, could you please help me out want to configure in
> global
> level so that I don't need mention in each routes as file end point is
> common to all routes is same .
>
> Thanks,
> Abhinay K
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Global-level-Configuration-for-multiple-routes-with-same-file-endpoints-tp5786341.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>