Reputation: 2255
I am trying to use "Scheduler component-http://camel.apache.org/scheduler.html but I am getting error. I need to fire scheduler every 60s and call my bean. I picked up the example from documentation and tried to implement it as is but it fails.
public class SchedulerRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("scheduler://foo?period=6000&delay=50").to("bean:logBean?method=sayHello");
}}
I get this error:
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)
I tried TIMER component and that works flawlessly but not the scheduler.
THIS CODE WORKS WITH TIMER COMPONENT
public class SchedulerRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("timer://foo?fixedRate=true&period=6000").to("bean:logBean?method=sayHello");
}}
Any ideas what am I missing here?
Upvotes: 1
Views: 3549
Reputation: 55555
That was a mistake in the scheduler documentation. There is no option named period
. You should use delay
to set how often to trigger. I am updating the documentation now, so the website is correct next time its generated.
http://camel.apache.org/scheduler
This is also what the exception message tells you: Unknown parameters=[{period=6000}
Upvotes: 1