Apache Camel Scheduler错误:无法解析端点

时间:2015-04-30 17:45:09

标签: java apache timer apache-camel

我正在尝试使用“调度程序组件 - http://camel.apache.org/scheduler.html但我收到错误。 我需要每隔60秒触发一次调度程序并调用我的bean。我从文档中获取了示例并尝试按原样实现它,但它失败了。

public class SchedulerRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
    from("scheduler://foo?period=6000&delay=50").to("bean:logBean?method=sayHello");
}}

我收到此错误:

org.apache.camel.FailedToCreateRouteException: Failed to create route route2: Route(route2)[[From[scheduler://foo?period=6000&delay=50]] -... because of Failed to resolve endpoint: scheduler://foo?delay=50&period=6000 due to: Failed to resolve endpoint: scheduler://foo?delay=50&period=6000 due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{period=6000}]
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:190)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:841)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:2895)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2618)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:167)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2467)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2463)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2463)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2432)
at com.acn.cs.filedownloader.MainApp.main(MainApp.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

我尝试了TIMER组件,它可以完美运行但不是调度程序。

此代码与定时器组件一起工作

public class SchedulerRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
    from("timer://foo?fixedRate=true&period=6000").to("bean:logBean?method=sayHello");
        }}

任何想法我在这里缺少什么?

1 个答案:

答案 0 :(得分:1)

这是调度程序文档中的错误。没有名为period的选项。您应该使用delay来设置触发的频率。我现在正在更新文档,因此下次生成时网站是正确的。

http://camel.apache.org/scheduler

这也是异常消息告诉您的内容:未知参数= [{period = 6000}