So, I essentially have two RouteBuilders. The MainRouteBuilder uses the services of the PipelineRouteBuilder to create the routes. RouteInitializer is a Spring bean which acts as a controller mainly interfacing with spring and issuing a new on MainRouteBuilder.
Everything works fine and the application initializes and runs. At a later time, however, I want to use the PipelineRouteBuilder directly to create a route at runtime and configure a ProducerTemplate to point to this new route. So, I do something like this: public ProducerTemplate newSyncProducerTemplate() { try { final String endpointName = "direct://sync.handle.event" + syncHandleEndpointCounter++; //Add the route to the context // camelContext .addRoutes( new PipelineRouteBuilder( camelContext, order--, endpointName, MainRouteBuilder.DIRECT_ERROR_QUEUE_ENDPOINT_NAME, getPipelineBeanCollection() ) ); final ProducerTemplate producerTemplate = DefaultProducerTemplate .newInstance( camelContext, endpointName ); producerTemplate.start(); return producerTemplate; } catch (final Exception e) { throw new RuntimeException("Unexpected exception during starting of producer", e); } } The PipelineRouteBuilder has a configure method which looks like this (it just builds the route from endpointName passed in): @Override public void configure() throws Exception { final RouteDefinition routeDefinition = from(endpointName) .routeId(endpointName) .startupOrder(order) .errorHandler( deadLetterChannel( deadLetterEndpointName ) .useOriginalMessage() .maximumRedeliveries(0) ); //Add the beans // for (final Object bean : beans) routeDefinition.bean(bean); } However, when ever I issue a template.sendBody(): return (EventData) template .sendBody( producer.getDefaultEndpoint(), ExchangePattern.InOut, data ); I always get a: org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint: Endpoint[direct://sync.handle.event0]. So, somehow creating a route definition from(endpointName) does not attach the route to the direct endpoint. I stepped through the code to see that this occurs inside DirectProducer when a call on endpoint.getConsumers() returns null, because the key (direct://sync.handle.event0) is not in the map of consumers for the endpoint. Again, using the PipelineRouteBuilder, from within MainRouteBuilder seems to be working just fine, so I am not sure why it's not working when I just want to use the PipelineRouteBuilder to create a dynamic route at a later time. In the MainBuilder, I use the same method to build routes from a vm:// which are then added to a collection of endpoints and are used in a load balancer definition: for (int i = 0; i < pipelinesCount; i++) { //Get the definition // final String pipelineEndpointDefinition = String .format( "vm://%s?size=%d&blockWhenFull=true&pollTimeout=%d", newEndpointName(name, i), queueSize, pollTimeout ); //Define a route for the endpoint // getContext() .addRoutes( new PipelineRouteBuilder( getContext(), order(), pipelineEndpointDefinition, DIRECT_ERROR_QUEUE_ENDPOINT_NAME, pipelineBeansSupplier.get() ) ); //Add endpoint to our result of pipelines // result .add( endpoint(pipelineEndpointDefinition) ); } The only difference I see is that here, I am using vm:// while in another case, I am using direct:// I really don't need all the workings of vm:// in the case where things are failing, so I wanted to use a simple direct:// . Any hints of where to look or what I am missing would be greatly appreciated. Thanks. -AP_ -- View this message in context: http://camel.465427.n5.nabble.com/Not-sure-why-I-get-DirectConsumerNotAvailableException-No-consumers-available-on-endpoint-tp5770808.html Sent from the Camel - Users mailing list archive at Nabble.com.