2015-04-22 36 views
5

Ho un problema con Camel e quarzo. mi vuoi anche eseguire un grilletto con quarzo Così ho scritto questo semplice codice, dove voglio stampare il tempo ogni due secondi sulla console:Utilizzo del timer con quarzo e Apache Camel

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(); 
    } 
} 

e ottengo questa eccezione: 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

comincio dicendo che ho inserito nel pom.xml la dipendenza:

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

dove camel.version è 2.15.1

Qualcuno può aiutarmi?

risposta

4

Stai importando il componente cammello-quarzo nel tuo file pom.xml durante il tentativo di utilizzare il vecchio componente al quarzo.

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

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

Provate il seguente URI per il percorso:

quartz2://myTimer?trigger.repeatInterval=2000&trigger.repeatCount=-1 
+0

ho provato, ora io ottenere un'eccezione con lo stesso tipo ma la causa è " Nessun componente trovato con schema: flusso "mentre prima era" Nessun componente trovato con schema: quarzo ". –

+2

Stai utilizzando il componente stream come endpoint, lo hai importato anche tu in pom.xml? Aggiungi la dipendenza Maven trovata qui: http://camel.apache.org/stream.html – Luke

+0

Viene eseguito ma ora non stampa l'ora. Stampa solo "L'ora corrente è". –