繁体   English   中英

骆驼标准化豆未注册

[英]Camel normalizer bean not registered

我正在尝试以在此处编写的方式来实现规范化器: http : //camel.apache.org/normalizer.html

我收到此异常:

org.apache.camel.NoSuchBeanException: No bean could be found in the registry for
: normalizer

我在RouteBuilder中的.configure()如下所示:

public void configure() throws Exception {

    JndiContext context = new JndiContext();
    context.bind("normalizer", new MyNormalizer());

    CamelContext camelContext = new DefaultCamelContext(context);
    camelContext.addRoutes(this);

    from("activemq:queue:input.splitter")
            .split().tokenizeXML("person").streaming()
            .to("activemq:queue:output.splitter");

    from("activemq:queue:input.normalizer")
            .choice()
            .when().xpath("//persons/person/position").to("bean:normalizer?method=positionChange")
            .end()
            .to("activemq:queue:output.normalizer");

}

规范化器如下所示:

public class MyNormalizer {
    public void positionChange(Exchange exchange, @XPath("//persons/person/position") String name) {
        exchange.getOut().setBody(createPerson(name));
    }

    private String createPerson(String name) {
        return name;
    }
}

我找到了一种有关将这段代码添加到RouteBuilder中的解决方案:

JndiContext context = new JndiContext();
context.bind("normalizer", new MyNormalizer());

CamelContext camelContext = new DefaultCamelContext(context);

但这没有任何结果。 那么这可能是什么问题呢?

找到了解决方案。 该Bean必须在conf / camel.xml中指定。 在我的情况下,定义如下所示:

<bean name="normalizer" id="normalizer" class="com.myroute.route.normalizer.MyNormalizer"/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM