如何丝般地过滤器内部水龙头 [英] How to wire tap inside a filter in camel

查看:196
本文介绍了如何丝般地过滤器内部水龙头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的骆驼和我有导线自来水给定的骆驼应用程序的路径内的过滤器。该应用程序只使用XML的味道。因为我可以添加<窃听> 任何标记(我没有得到任何错误),我想这应该是可能的内部?
下面是用铁丝按路线:

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&amp;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>

最后线材龙头类:

And finally the wire tap class:

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组件
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"/>

和头脑可以给豆你想要的任何标识,你不必把它叫做窃听。

And mind you can give the bean any id you want, you dont have to call it wireTap.

这篇关于如何丝般地过滤器内部水龙头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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