【问题标题】:i am not able to call the method using apache camel quartz2我无法使用 apache camelquartz2 调用该方法
【发布时间】:2013-10-25 10:10:57
【问题描述】:

我需要调用基于 cron 模式的方法。这是我的 java 代码。我在其中包含了一个方法,我需要调用这个方法。我在 google 中尝试但不知道如何调用。

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();    
}

 }

我也不确定这是否正确

【问题讨论】:

  • 我正在使用 apache 骆驼
  • 您提供的代码 sn-p 并没有表明您已经启动了骆驼上下文。在骆驼上下文中调用 start 方法以使其工作。但是我觉得在 JSP 页面中启动骆驼上下文和在其中调用方法的路由很奇怪。你能解释一下你的完整用例吗?
  • 还发布在 Camel 用户邮件列表中,其中解释了答案 - camel.465427.n5.nabble.com/…

标签: java apache-camel quartz-scheduler


【解决方案1】:

您应该查看有关 bean 绑定的文档 (Here)。我认为您的路线会更好,如下所示:

from("quartz2://myGroup/myfirstrigger?cron=0/2+*+*+*+*+?")
  .bean(Schedule.class, "show");

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2016-12-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-11
相关资源
最近更新 更多