Search code examples
javaapache-camelcamel-ftp

Apache Camel Chaining Routes together


Here is the scenario I'm trying to implement:

Remote to an FTP Server Copy a large file (3gig+ in size) to a local folder Stream the local file into a Camel Processor, batching the file 100 lines at a time. Write the Batched set of lines out to a Kafka topic.

Now I've got the first part figured out. I'm able to read the file in to a local directory. The problem is, how do I kick of the second Route (Streaming the Local file to Kafka)? Is there a way to chain all of these tasks together in the same route, or should I have multiple routes:

1 for the FTP -> LOCAL FILE and then 1 for the LOCAL FILE -> KAFKA

If I need two routes, then what's the best way to kick off the second route after the first route is done.

Thanks for any assistance. Additionally, here is the FTP portion that already works.

public void configure() throws Exception {
    from(fullyBuiltFtpPath)
            .routeId("FTP ENDPOINT CONSUMER" + UUID.randomUUID().toString())
            .process(new FtpToLocalFileProcessor())
            .to("file:c:\\temp")
            .log(LoggingLevel.INFO, "FILENAME: ${header.CamelFileName}").end();
}

Solution

  • I ended up splitting the routes into two distinct routes:

    1.) Retrieve File from FTP Server and store it in a local temp Directory 2.) Start up a file route to listen to the local temp directory and consume the file.

    This isn't ideal, but it works for now. Thanks for the help.