apache-camel - Apache Camel Cron 作业调度与quartz2
问题描述
我的目标是从周一到周五每天 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:在注册表中找不到 bean:quartz2 类型:org.apache.camel.spi.ScheduledPollConsumerScheduler 2)我明白我的程序应该在安排作业时运行。我应该如何确保。我的意思是我需要在我设置的时间内运行这个程序吗?我应该为Thread.sleep()中的睡眠赋予什么价值?3)如果它无法获取文件,我怎样才能让它重试?
请注意:除调度程序外,我的程序运行良好,即它能够从 FTP 服务器获取文件并下载到我的本地位置。
请帮助解决问题。
解决方案
您可以每天在特定时刻启动骆驼上下文。但是为什么不总是运行它(所以需要 Thread.sleep)
奇怪的异常可能是由于缺少一些类路径问题
推荐阅读
- python - 错误:字段大于字段限制 (131072)
- dji-sdk - UpdateJoystickValue 在 Windows-SDK 中不起作用
- ios - UITableView - 标题高度更改后重新定位单元格
- java - 没有找到 messages_XX.properties
- ruby-on-rails - 使用 Prawn 和 Carrierwave 上传 PDF 而不将文件保存在磁盘上
- c# - 如何在 C# 中编辑匿名动态列表
- wordpress-theming - yarn start localhost:3000 未加载
- java - 如何使用 Selenium WebDriver 或 JS 等待 iframe 内容加载?
- snakemake - 使用 Snakemake 时如何修复“文件名太长”错误
- python - NameError 即使变量被初始化