How to set value for antInclude attribute from exchange property in apache camel

我的未来我决定 提交于 2019-12-20 06:28:33

问题


I am adding a property to exchange at runtime from the request.

exchange.setProperty("filePattern", String.format("*%s*", routeConfig.getFilePattern()))

Later, I am trying use the property for antInclude attribute as below

file:source?readLock=changed&antInclude=${exchangeProperty.filePattern}

Above code is not working, route created as below during runtime in log

 file://source?antInclude=%24%7BexchangeProperty.filePattern%7D&readLock=changed

回答1:


Aha! I see what you are trying to do here. Simple expressions won't work that way with a Polling Consumer like File2.

If you are using Camel 2.16+, you can use pollEnrich to get a behavior that you are trying to get here. It would be something like

from("direct:inputFileRoute")
                .pollEnrich("file:src/data?noop=true&antInclude=${exchange.filePattern}")
                .log("File Pattern is: ${exchangeProperty.filePattern}");

On a sidenote, are you sure you have to tweak the antiInclude option on the File component for every exchange? It looks like an overkill but I am unable to make a judgement based on the very limited input available here. Perhaps what you are looking for is Camel Properties



来源:https://stackoverflow.com/questions/54377346/how-to-set-value-for-antinclude-attribute-from-exchange-property-in-apache-camel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!