[英]Camel normalizer bean not registered
I'm trying to implement a normalizer the way it's written here: http://camel.apache.org/normalizer.html 我正在尝试以在此处编写的方式来实现规范化器: http : //camel.apache.org/normalizer.html
I'm getting this exception: 我收到此异常:
org.apache.camel.NoSuchBeanException: No bean could be found in the registry for
: normalizer
My .configure() in the RouteBuilder looks like this: 我在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");
}
The normalizer looks like this: 规范化器如下所示:
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;
}
}
I found one solution about adding that piece of code into the RouteBuilder: 我找到了一种有关将这段代码添加到RouteBuilder中的解决方案:
JndiContext context = new JndiContext();
context.bind("normalizer", new MyNormalizer());
CamelContext camelContext = new DefaultCamelContext(context);
But it didn't give any result. 但这没有任何结果。 So what could be the problem here?
那么这可能是什么问题呢?
The solution was found. 找到了解决方案。 The bean has to be specified in the conf/camel.xml.
该Bean必须在conf / camel.xml中指定。 In my case the definition looks like this:
在我的情况下,定义如下所示:
<bean name="normalizer" id="normalizer" class="com.myroute.route.normalizer.MyNormalizer"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.