如何在骆驼的过滤器内接线 [英] How to wire tap inside a filter in camel
问题描述
我是骆驼的新手,我必须在给定的骆驼应用程序的路由内连接过滤器.该应用程序仅使用 xml-flavor.因为我可以在任何标签中添加 <wireTap>
(我没有发现错误),所以我想这应该是可能的?!这是带线分接头的路线:
I am new to camel and i have to wire tap a filter inside a route of a given camel application. The application only uses xml-flavor. Because i could add <wireTap>
inside any tag (i get no error) i guess it should be possible?!
Here is the route with wire tap:
<route id="cep-output-postpaid" autoStartup="true">
<from
uri="someUri" />
<log message="Output: ${body}" />
<to
uri="file:someFile?fileName=result.csv&fileExist=Append"></to>
<filter>
<method ref="filterAfterDownTime" method="numberOfDaysToFilter(${body}, 100)" />
<process ref="processor1"></process>
<throttle timePeriodMillis="10000">
<constant>40</constant>
<wireTap uri="direct:wireTap"/>
<to uri="someWsdlService"></to>
</throttle>
<process ref="processor1"></process>
</filter>
<log message="Done CEP Engine Output" />
</route>
bean 是这样引用的:
The bean is referenced like this:
<bean id="wireTap" class="somePackage.WireTap"></bean>
最后是电线分接头类:
public class WireTap {
public PcrfEdrPostpaidWireTap(){
System.out.println("wiretap constructor called");
}
@Handler
public void handleBody(String body){
System.out.println("Wiretap says:" + body);
}
}
问题既不是构造函数也不是方法被调用,而是路由正在运行并产生其输出.有任何想法吗?提前致谢.
The problem is neither the constructor nor the method is called but the rout is running and produces its output. Any ideas? Thanks in advance.
其他问题:这里如何使用seda"?(我想将窃听与处理分离)和是否可以给窃听一个参数(例如窃听文件的路径)
Additional Questions: How to use "seda" here? (i want to decouple the wiretap from the processing) and Is it possible to give the wiretap a parameter (e.g. path to a file for the wire tap)
推荐答案
啊,如果你想在 bean 上调用一个方法,你应该使用 bean 组件http://camel.apache.org/bean
Ah you should use the bean component if you want to call a method on a bean http://camel.apache.org/bean
所以改变
<wireTap uri="direct:wireTap"/>
到
<wireTap uri="bean:wireTap"/>
请注意,您可以为 bean 指定任何您想要的 ID,您不必将其称为 wireTap.
And mind you can give the bean any id you want, you dont have to call it wireTap.
这篇关于如何在骆驼的过滤器内接线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!