我对骆驼和石英有问题。我想用 Quartz 执行触发器,所以我写了这个简单的代码,我想在控制台上每两秒打印一次时间:
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();
}
}
我得到这个例外: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
我首先说我已经在pom中插入了.xml依赖项:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-quartz2</artifactId>
<version>${camel.version}</version>
</dependency>
其中 camel.version 是 2.15.1
有人可以帮助我吗?
您正在将骆驼石英2 组件导入 pom.xml 文件中,同时尝试使用旧的石英组件。
石英:http://camel.apache.org/quartz.html
石英2:http://camel.apache.org/quartz2.html
尝试以下路由 URI:
quartz2://myTimer?trigger.repeatInterval=2000&trigger.repeatCount=-1