How do dynamic “from” endpoints and exchanges work in camel?

风格不统一 提交于 2019-12-01 11:58:56

You can achieve "dynamic from" with Content Enricher pattern.

Let's say your first route is used to add file name to the header for instance like this:

from("timer:trigger?repeatCount=1")
.routeId("define-file-name")
.setHeader("myHeader", constant("file.txt"))
.to("direct:start");

Then your second route can poll for that file using the information from the exchange header like this.

from("direct:start")
.routeId("poll-file")
.pollEnrich().simple("file://dir1?fileName=${in.header.myHeader}").timeout(10000)
.log("${body}");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!