骆驼 | RouteBuilder 何时在更新的文件上执行?
Camel | When does the RouteBuilder execute on updated files?
我设置了一个基本路线:
RouteBuilder route = new RouteBuilder() {
@Override
public void configure() throws Exception {
from("file:OrderSystem?fileName=orders.txt&noop=true")
.split(body().tokenize("\n"))
.process(OrderFactory)
.to("jms:queue:inqueue");
}
};
当我 运行 ctxt.start()
添加路由时,文件中的数据立即在我的 ActiveMQ 队列中。之后我有一个 Thread.sleep(999999)
,以确保 Camel 保持活动状态,但即使这样我的 orders.txt
文件也更新了新数据,队列中不再添加任何内容。如何将文件中的更新数据路由到我的队列?我需要执行什么来请求数据或观察变化?
(以及如何使用 camel 删除文件中的数据,而不是文件本身?)
感谢您的解释。
来自Camel File Component,参数noop
的描述是
If true, the file is not moved or deleted in any way. This option is
good for readonly data, or for ETL type requirements. If noop=true,
Camel will set idempotent=true as well, to avoid consuming the same
files over and over again.
实际上,您的路由每 500 毫秒(延迟的默认值)扫描一次文件夹并查找名称为 orders.txt
的文件。但是默认 idempotent
设置(由 noop
打开)会阻止您获取“相同”文件。
为了达到你的目的,你需要调整参数idempotentKey
来告诉Camel如何判断一个文件是否正在处理(默认设置是文件路径)。例如同时使用文件名和大小 idempotentKey=${file:name}-${file:size}
我设置了一个基本路线:
RouteBuilder route = new RouteBuilder() {
@Override
public void configure() throws Exception {
from("file:OrderSystem?fileName=orders.txt&noop=true")
.split(body().tokenize("\n"))
.process(OrderFactory)
.to("jms:queue:inqueue");
}
};
当我 运行 ctxt.start()
添加路由时,文件中的数据立即在我的 ActiveMQ 队列中。之后我有一个 Thread.sleep(999999)
,以确保 Camel 保持活动状态,但即使这样我的 orders.txt
文件也更新了新数据,队列中不再添加任何内容。如何将文件中的更新数据路由到我的队列?我需要执行什么来请求数据或观察变化?
(以及如何使用 camel 删除文件中的数据,而不是文件本身?)
感谢您的解释。
来自Camel File Component,参数noop
的描述是
If true, the file is not moved or deleted in any way. This option is good for readonly data, or for ETL type requirements. If noop=true, Camel will set idempotent=true as well, to avoid consuming the same files over and over again.
实际上,您的路由每 500 毫秒(延迟的默认值)扫描一次文件夹并查找名称为 orders.txt
的文件。但是默认 idempotent
设置(由 noop
打开)会阻止您获取“相同”文件。
为了达到你的目的,你需要调整参数idempotentKey
来告诉Camel如何判断一个文件是否正在处理(默认设置是文件路径)。例如同时使用文件名和大小 idempotentKey=${file:name}-${file:size}