Java Camel:向内部循环添加多个
我在代码中使用循环。我知道循环在出现第一个Java Camel:向内部循环添加多个,java,apache-camel,Java,Apache Camel,我在代码中使用循环。我知道循环在出现第一个到时中断,如中所述 现在,我有了一个路由定义,我希望在循环结束之前,在不同的通道之间进行路由。例如: .loop(simple("${header." + FILE_COUNT + "}")) .to("direct:file-iterator") .end() from("direct:file-iterator").id("file-iterator") .to("di
到时中断,如中所述
现在,我有了一个路由定义,我希望在循环结束之前,在不同的通道之间进行路由。例如:
.loop(simple("${header." + FILE_COUNT + "}"))
.to("direct:file-iterator")
.end()
from("direct:file-iterator").id("file-iterator")
.to("direct:read-file-checksum")
.to("direct:file-unzip")
在我的代码中,这种场景是否有解决方法,只有在第一次迭代后执行的第一个场景?此路径:
public void configure() {
from("direct:start")
.loop(2)
.log("CamelLoopIndex = ${header.CamelLoopIndex}")
.to("direct:file-iterator")
.end();
from("direct:file-iterator")
.id("file-iterator")
.log(" in file-iterator")
.to("direct:read-file-checksum")
.to("direct:file-unzip");
from("direct:read-file-checksum")
.log(" in read-file-checksum");
from("direct:file-unzip")
.log(" in direct:file-unzip");
}
}
导致以下输出:
[main] route1 INFO CamelLoopIndex = 0
[main] file-iterator INFO in file-iterator
[main] route2 INFO in read-file-checksum
[main] route3 INFO in direct:file-unzip
[main] route1 INFO CamelLoopIndex = 1
[main] file-iterator INFO in file-iterator
[main] route2 INFO in read-file-checksum
[main] route3 INFO in direct:file-unzip
这就是我所期望的。如果此路径对应于您的设置,那么您的问题不是循环问题,您应该研究直接:文件解压缩路径。请您重新表述您的问题,我不明白。是的,我的问题是在第一次迭代中,路由按以下方式完成:直接:文件迭代器->直接:读取文件校验和->直接:文件解压缩。但是在第二次迭代中,只执行direct:file iterator->direct:read file checksum path。在将消息路由到“direct:file iterator”之前,您需要更新exchange。没有执行。更新exchange是什么意思?你的意思是说我需要手动更改文件计数吗?你能在读取文件校验和和和fire解压之间放一个log语句吗。