如何从Apache骆驼的交换属性设置antInclude属性的值 [英] How to set value for antInclude attribute from exchange property in apache camel

查看:111
本文介绍了如何从Apache骆驼的交换属性设置antInclude属性的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在添加一个属性,以便在运行时根据请求进行交换.

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

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

稍后,我正在尝试使用antInclude属性的属性,如下所示

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

推荐答案

啊!我在这里看到您正在尝试做的事情.简单的表达式对于 File2 之类的轮询使用者将不起作用.

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

如果您使用的是Camel 2.16+,则可以使用 pollEnrich 来获得您试图到达这里的行为.就像

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}");

在旁注中,您确定每次交换都必须调整File组件上的antiInclude选项吗?看起来有些矫kill过正,但我​​无法根据此处提供的非常有限的信息做出判断.也许您正在寻找的是骆驼属性

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

这篇关于如何从Apache骆驼的交换属性设置antInclude属性的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆