Quantcast
Viewing all articles
Browse latest Browse all 5648

Suspend route after aggregator is complete

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()

Viewing all articles
Browse latest Browse all 5648

Trending Articles