Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using timer with Quartz and Apache Camel

I've a problem with Camel and quartz. I wanto to execute a trigger with Quartz so i wrote this simple code, where I want to print the time every two second on the console :

 public class TestQuartz {
    public static void main(String args[]) throws Exception {
        CamelContext context = new DefaultCamelContext();
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() {
                from("quartz://myTimer?trigger.repeatInterval=2000&trigger.repeatCount=-1").setBody().simple("Current time is ${header.firedTime}").to("stream:out");
            }
        });

        context.start();
        Thread.sleep(10000);
        context.stop();
    }
}   

And I obtain this exception: Exception in thread "main" org.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route(route1)[[From[quartz://myGroup/myTimerName?cron=0+0+8+... because of Failed to resolve endpoint: quartz://myGroup/myTimerName?cron=0+0+8+*+*+* due to: No component found with scheme: quartz

I start by saying that I've inserted in the pom.xml the dependency:

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-quartz2</artifactId>
            <version>${camel.version}</version>
        </dependency>

where camel.version is 2.15.1

Can someone help me?

like image 442
Milioli Luca Avatar asked Apr 22 '15 11:04

Milioli Luca


1 Answers

You're importing the camel-quartz2 component in your pom.xml file whilst trying to use the old quartz component.

Quartz: http://camel.apache.org/quartz.html

Quartz2: http://camel.apache.org/quartz2.html

Try the following URI for the route:

quartz2://myTimer?trigger.repeatInterval=2000&trigger.repeatCount=-1
like image 158
Luke Avatar answered Sep 23 '22 15:09

Luke