我需要调用基于cron模式的方法。这是我的java代码。其中我包含了一种方法,这个方法我需要调用。我在谷歌尝试但不知道如何调用。
public class Schedule {
int i;
public String show()
{
return "hi"+i++;
}
public static void main(String args[])throws Exception
{
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("quartz2://myGroup/myfirstrigger?cron=0/2+*+*+*+*+?").to(new Schedule().show());
}
});
context.start();
}
}
我不确定这是对还是
答案 0 :(得分:0)
您应该查看有关bean绑定的文档(Here)。我认为您的路线会更好,如下所示:
from("quartz2://myGroup/myfirstrigger?cron=0/2+*+*+*+*+?")
.bean(Schedule.class, "show");