Check file is processed through all routes of camel using aggregator

时间:2016-09-01 06:20:45

标签: java apache-camel apache-kafka cassandra-2.1

I have a camel application where, I am reading files from FTP source. Then the file goes through multiple routes, like one route goes to cassandra for storage, one route process the data and push pivoted data to Kafka topic etc

I want to mark the file processed when it goes through all routes and reaches till the end. This way I can build a processing completed log based on file name.

One way, That I can think of is to implement aggregator, where each route will send completion notification in exchange header and then based on the completion criteria logic in aggregator, I will mark that file as processed.

How will I write such aggregator in java?

1 个答案:

答案 0 :(得分:3)

您可以尝试使用multicast

from("direct:start")
    .multicast()
        .to("direct:a","direct:b")
    .end()
    // Won't run until the sub routes are complete
    .process(new MarkFileAsCompletedProcessor())
    .log("Finished multicast");

from("direct:a")
    .log("Processing a")
    .to("mock:endOfA");

from("direct:b")
    .log("Processing b")
    .to("mock:endOfB");