You use a scheduler to give an interval to consume files.

Why not using the file component to consume the files (see
https://camel.apache.org/file2.html)? It has since Camel 2.12 a "scheduler"
property for cron jobs and even in older versions you can use "delay" to
schedule directory polling.

With the file component you can use "preMove" and similar options to move
the files in progress away to protect them from being consumed multiple
times (what I guess is the reason to suspend the route in your case).

Regards
Stephan


On Thu, Mar 6, 2014 at 3:10 PM, toxels87 <[email protected]> wrote:

> Hi,
>
> I have a route that gets a list of txt  files from one folder, zips the
> batch of files with an aggregator and then sends this zipfile over FTP to
> the endpoint.
> The schedule is controlled by a cron trigger and should fire every 5
> minutes.
>
> The problem is that once the cron has triggered, the route remains open.
>
> I want to suspend the route after the aggregator has sent one zipfile, and
> then wait 5 minutes to process the next batch of files.
>
>  from(start)
>                 .routeId(routeId)
>                 .routePolicy(scheduledRoutePolicy)
>                 .noAutoStartup() // no auto startup, startup time
> controlled
> by CRON
>                 .aggregate(constant(true), new
> CustomZipAggregationStrategy())
>                 .eagerCheckCompletion()
>                 .completionFromBatchConsumer()
>                 .to(end)
>                 .log(LoggingLevel.INFO, "### ftp.route.filter :
> CamelBatchComplete=TRUE, TOTAL files transferred:
> ${property.CamelBatchSize}")
> //                 suspend route until next cron trigger
>
> .filter(property(Exchange.BATCH_COMPLETE).isEqualTo(Boolean.TRUE))
>                 .process(
>                         new Processor() {
>                             @Override
>                             public void process(Exchange exchange) throws
> Exception {
>                                 System.out.println("Suspending Route " +
> routeId);
>                                 LOGGER.info("### cronfile.route - Full file
> Transfer Complete: Route SUSPENDED");
>                                 CamelContext context =
> exchange.getContext();
>                                 // remove exchange from the in flight
> registry so we can stop this route without trouble
>
> context.getInflightRepository().remove(exchange);
>                                 context.suspendRoute(routeId);
>                             }
>                         }
>                 )
>                 .end()
>         ;
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Suspend-route-after-aggregator-is-complete-tp5748388.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Reply via email to