我是Apache camel和quartz调度程序的新手。我试图在集成中使用它们但无法做到。我在“Camel in Action”一书中找到了一篇小文章但我没有设法运行该程序 - 这是我的代码
package com.cockpitconfig.schedulars;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
public class TestScheduler {
public static void main(String args[]) throws Exception {
CamelContext context = new DefaultCamelContext();
context.disableJMX();
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
from(
"quartz://myTimer?trigger.repeatInterval=2000&trigger.repeatCount=-1")
.setBody().simple("Current time is ").to("stream:out");
}
});
context.start();
Thread.sleep(10000);
context.stop();
}
}
但是它给出了错误
Exception in thread "main" java.lang.InstantiationError: org.quartz.SimpleTrigger
at org.apache.camel.component.quartz.QuartzComponent.createEndpoint(QuartzComponent.java:119)
at org.apache.camel.component.quartz.QuartzComponent.createEndpoint(QuartzComponent.java:54)
at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:75)
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:419)
at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:47)
at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:189)
at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:110)
at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:116)
at org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:73)
at org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:88)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:751)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:174)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:610)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1514)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1306)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1213)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:65)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1191)
at com.cockpitconfig.schedulars.TestScheduler.main(TestScheduler.java:24)
有人能解决这个问题吗?
答案 0 :(得分:0)
答案 1 :(得分:0)
目前的camel-quartz插件文档并不明显,但是从Camel 2.11.0开始,它只与Quartz 1.x兼容,并且与Quartz 2.x(已经存在了几年)不兼容因为Quartz 2.x与Spring 3.0不兼容(而且Camel已经表示它现在将保持Spring 3.0的兼容性。
这在this Camel JIRA issue上有记录。