如何使用apache Camel文件组件在bean方法中接收文件内容?

时间:2015-07-29 05:41:49

标签: java apache-camel

我正在尝试使用apache camel文件组件读取文件:

consBean已正确注册。

ConsumerBean有以下方法:

public void beanRoute(File body){

            System.out.println("Bean method is called -->" +body);
        }

我的RouteBuilder有以下代码:

public class KafkaRouter extends RouteBuilder {
    @Override
    public void configure() throws Exception {
    from("file:C:\\ccd?fileName=CCD.xml&delay=5000&noop=true.to("bean:consBean?method=beanRoute(${body})");
}

My Test Class只需创建新的RouteBuilder:

构造函数代码:

public CamelTest(){

        this.ctx =new DefaultCamelContext();
        PropertyPlaceholderDelegateRegistry reg = (PropertyPlaceholderDelegateRegistry)ctx.getRegistry();

        ((JndiRegistry)reg.getRegistry()).bind("consBean", new ConsumerBean());
        PropertiesComponent properties=new PropertiesComponent();

        properties.setLocation("com/camel/test/props.properties");
        ctx.addComponent("properties",properties);

    }

主要方法代码:

ctx.addRoutes(new KafkaRouter());
        ctx.start();

代码运行成功,但无法在bean方法中获取任何输出(未调用bean方法)

0 个答案:

没有答案