带有crystal2的Apache Camel Cron作业计划

问题描述 投票:0回答:1

我的目标是安排从周一至周五在每天15:00进行工作。下面是我的代码:

CamelContext _ctx = new DefaultCamelContext();
_ctx.addRoutes(new RouteBuilder() {

            public void configure() throws Exception {
from("ftp://Sid@localhost:21/equityFeedsProcessing/?password=sid#ftp&stepwise=false&useList=false&ignoreFileNotFoundOrPermissionError=true&fileName=data-sample.csv&"
                        + "scheduler=quartz2&scheduler.cron=00+15+*+*+MON-FRI")
          .to("file:src/main/resources/?fileName=abc.csv");

            }

        });

        _ctx.start();
         Thread.sleep(30000);
        _ctx.stop();

问题:1)我收到一个非常奇怪的异常:原因:org.apache.camel.NoSuchBeanException:在注册表中找不到以下类型的豆:org.apache.camel.spi.ScheduledPollConsumerScheduler的bean2)我知道计划作业后我的程序应该正在运行。我应该如何确保。我的意思是我需要在设定的时间内运行该程序吗?在Thread.sleep()中应该给睡眠值什么?3)另外,如果无法获取文件,该如何重试?

请注意:例外,我的程序的调度程序运行得很好,即它能够从FTP服务器获取文件并下载到我的本地位置。

请帮助解决问题。

apache-camel quartz-scheduler quartz
1个回答
1
投票

您可以每天在某个特定时刻启动骆驼上下文。但是为什么不总是运行它(因此需要Thread.sleep)

有关重试机制,请参见https://camel.apache.org/manual/latest/faq/how-do-i-handle-failures-when-consuming-for-example-from-a-ftp-server.html

奇怪的异常可能是由于缺少一些类路径问题

© www.soinside.com 2019 - 2024. All rights reserved.