[英]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.