msadasjwd
msadasjwd

Reputation: 125

Apache camel cron error because of Failed to resolve endpoint: cron

I try to use camel with cron expressions. Because i need 3 different things to do with cron expressions, 3 different timings. Daily, monthly and instant check of files in remote. I can not do it with spring batch. So, i chose camel.

@Override
public void configure() throws Exception {

    onException(Exception.class)
        .process(lifeDispatchExceptionProcessor)
        .handled(true)
        .transform()
        .simple("Error reported: ${exception.message} - cannot process this message.");

    from("cron:tab?schedule=0/3 0/1 * 1/1 * ? *")
        .setBody().constant("event")
        .log("${body} faafs")
        .process(documentProcessor);
    
}

I added this method as hello world but even this is not working:

//org.apache.camel.spring.boot.CamelSpringBootInitializationException: org.apache.camel.FailedToCreateRouteException: // Failed to create route route147: Route(route147)[[From[cron:tab?schedule=0/3 0/1 * 1/1

  • ? ]... // because of Failed to resolve endpoint: cron://tab?schedule=0%2F3+0%2F1++1%2F1++%3F+ due to: No component found with scheme: cron

This is pom.xml:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-core</artifactId>
    <exclusions>
        <exclusion>
            <artifactId>jaxp-ri</artifactId>
            <groupId>com.sun.xml.parsers</groupId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-quartz2</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-spring</artifactId>
    <exclusions>
        <exclusion>
            <artifactId>jaxp-ri</artifactId>
            <groupId>com.sun.xml.parsers</groupId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-jackson</artifactId>
    <exclusions>
        <exclusion>
            <artifactId>jaxp-ri</artifactId>
            <groupId>com.sun.xml.parsers</groupId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-jms</artifactId>
    <exclusions>
        <exclusion>
            <artifactId>jaxp-ri</artifactId>
            <groupId>com.sun.xml.parsers</groupId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-ftp</artifactId>
    <exclusions>
        <exclusion>
            <artifactId>jaxp-ri</artifactId>
            <groupId>com.sun.xml.parsers</groupId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-bindy</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-crypto</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-jpa</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-spring-boot-starter</artifactId>
    <version>2.18.1</version>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-kafka</artifactId>
    <exclusions>
        <exclusion>
            <artifactId>jaxp-ri</artifactId>
            <groupId>com.sun.xml.parsers</groupId>
        </exclusion>
    </exclusions>
</dependency>

I want to be able to use cron expressions, so camel will check according to cron expresions. Any help?

Upvotes: 0

Views: 1172

Answers (1)

hk6279
hk6279

Reputation: 1879

From Camel Doc for Cron Components, you have to inject dependency camel-cron before use.

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-cron</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

The cron component available in Camel since version 3.1. For version older than 3.1, you may consider to use the cron trigger method under quartz2 component.

Upvotes: 1

Related Questions