camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From druminski <drumin...@gmail.com>
Subject New camel component which dynamically adds routes when it starts.
Date Mon, 10 Dec 2012 10:43:48 GMT
Hello, 

I am working on a new camel component. The Purpose of the new component is
to simplify routes like this:

from("ref:myQueue")
    .to("nmr:nmrEndpoint");
    
from("nmr:nmrEndpoing")
    .("mock:result");
    
To route like this:

from("nmrref:myQueue?nmr=nmrEndpoint")
    .to("mock:result");
    
So I would like to add dynamically two routes (which send and receive
exchanges from "nmr" component) when "nmrref" component/consumer starts. 
At the moment I have NmrRefConsumer class which extends DefaultConsumer. The
doStart() method is overriden:

    @Override
    protected void doStart() throws Exception {
        super.doStart();

        RouteBuilder routeBuilder = new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("ref:" + refAddr)
                    .to("nmr:" + nmrAddr);

                from("nmr:" + nmrAddr)
                    .process(getProcessor());
            }
        };

        endpoint.getCamelContext().addRoutes(routeBuilder);
        for(RouteDefinition routeDefinition :
routeBuilder.getRouteCollection().getRoutes()) {
            endpoint.getCamelContext().startRoute(routeDefinition);
        }
    }
    
But it looks like this dynamic routes doesn't start in camelContext. Do you
know why and how can I fix this?

Thanks for reply.

Best regards
Lukasz Druminski



--
View this message in context: http://camel.465427.n5.nabble.com/New-camel-component-which-dynamically-adds-routes-when-it-starts-tp5723833.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message