javaapache-camelactivemq-classicintegration-patterns

Camel normalizer bean not registered


I'm trying to implement a normalizer the way it's written here: 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:

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:

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?


Solution

  • The solution was found. The bean has to be specified in the conf/camel.xml. In my case the definition looks like this:

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