Search code examples
javakotlincronapache-camel

Route camel cron expression


I would like to include a scheduler in my camel route that will start it every day at 8. This is my route that takes a file from an ftp:

from(
            "$uri?" +
                    "password=RAW($pass)" +
                    "&include=$source_file_type" +
                    "&passiveMode=true" +
                    "&delete=true"
        )
            .log("Connected to FTP")

I tried to put in my from this:

"&scheduler.cron=$cron_expression"

but it did not work


Solution

  • Quoting the docs for scheduler property of FTP Component.

    To use a cron scheduler from either camel-spring or camel-quartz component. The value can be one of: none, spring, quartz

    To use a cron style expression, you need to couple FTP with one of the two scheduler options mentioned in the docs.

    For using quartz as a scheduler in Camel 3.x, try this

    1. Add dependency to camel-quartz
    2. Add params scheduler=quartz&scheduler.cron=<your crown expression> to FTP route definition

    If you are using Camel 2.x,

    1. Add dependency to camel-quartz2
    2. Add params scheduler=quartz2&scheduler.cron=<your crown expression> to FTP route definition