You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "dattu.1729" <da...@gmail.com> on 2011/08/01 16:49:41 UTC

apache came with quartz - no concurrent execution

Hi,

I am using camel->quartz component. My use case is "Have to merge all
avaliable files for every 5 mins." In this example, I don't want to run
parallel thread.

final FileEndpoint enpoint = (FileEndpoint)endpoint("file:src/ip/ch1");
final RouteBuilder route = new Filecopy("mergeRoute",enpoint);
context.addRoutes(route);
from("quartz://myTimer/myTimerName?cron=5+*+*+*+*+?&stateful=true")
				.process(new Processor() {
               
					
					@Override
					public void process(Exchange exchange) throws Exception {
						File[] files = enpoint.getFile().listFiles();
						if(files != null && files.length > 0){
							context.startRoute("mergeRoute");
						} else {
							System.out.println("--No Files--");
						}
					}
				
});

Filecopy class is another Route, which will do file merge and oncompletion
will stop Route.

If merging is taking more than 5mins, another Route is starting and merging
files parallel. To stop this parallel processing what i need to do? 



--
View this message in context: http://camel.465427.n5.nabble.com/apache-came-with-quartz-no-concurrent-execution-tp4655221p4655221.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: apache came with quartz - no concurrent execution

Posted by Magnus Palmér <ma...@gmail.com>.
In Quartz the first parameter is seconds.
To execute every 5 min cron-style use this cron expression (works for me):
cron=0+0/5+*+*+*+?

Brgds, Magnus Palmér

2011/8/1 dattu.1729 <da...@gmail.com>

> Hi,
>
> I am using camel->quartz component. My use case is "Have to merge all
> avaliable files for every 5 mins." In this example, I don't want to run
> parallel thread.
>
> final FileEndpoint enpoint = (FileEndpoint)endpoint("file:src/ip/ch1");
> final RouteBuilder route = new Filecopy("mergeRoute",enpoint);
> context.addRoutes(route);
> from("quartz://myTimer/myTimerName?cron=5+*+*+*+*+?&stateful=true")
>                                .process(new Processor() {
>
>
>                                        @Override
>                                        public void process(Exchange
> exchange) throws Exception {
>                                                File[] files =
> enpoint.getFile().listFiles();
>                                                if(files != null &&
> files.length > 0){
>
>  context.startRoute("mergeRoute");
>                                                } else {
>
>  System.out.println("--No Files--");
>                                                }
>                                        }
>
> });
>
> Filecopy class is another Route, which will do file merge and oncompletion
> will stop Route.
>
> If merging is taking more than 5mins, another Route is starting and merging
> files parallel. To stop this parallel processing what i need to do?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/apache-came-with-quartz-no-concurrent-execution-tp4655221p4655221.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: apache came with quartz - no concurrent execution

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You may want to try the simple trigger instead of cron based, to
indicate a 5 minute gap between tasks.

Or use the timer component instead?
http://camel.apache.org/timer
And use the fixedRate=true option.

On Mon, Aug 1, 2011 at 4:49 PM, dattu.1729 <da...@gmail.com> wrote:
> Hi,
>
> I am using camel->quartz component. My use case is "Have to merge all
> avaliable files for every 5 mins." In this example, I don't want to run
> parallel thread.
>
> final FileEndpoint enpoint = (FileEndpoint)endpoint("file:src/ip/ch1");
> final RouteBuilder route = new Filecopy("mergeRoute",enpoint);
> context.addRoutes(route);
> from("quartz://myTimer/myTimerName?cron=5+*+*+*+*+?&stateful=true")
>                                .process(new Processor() {
>
>
>                                        @Override
>                                        public void process(Exchange exchange) throws Exception {
>                                                File[] files = enpoint.getFile().listFiles();
>                                                if(files != null && files.length > 0){
>                                                        context.startRoute("mergeRoute");
>                                                } else {
>                                                        System.out.println("--No Files--");
>                                                }
>                                        }
>
> });
>
> Filecopy class is another Route, which will do file merge and oncompletion
> will stop Route.
>
> If merging is taking more than 5mins, another Route is starting and merging
> files parallel. To stop this parallel processing what i need to do?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/apache-came-with-quartz-no-concurrent-execution-tp4655221p4655221.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



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