'No consumers available on endpoint: Endpoint[direct://LookUpRoute]

I'm new to Apache Camel. I'm trying to send an exchange from a java method to a route but it gives me "Caused by: org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint" error. I want to understand what exactly this error is and when do we get this?

@EndpointInject(uri = "direct:reportRoute")
private ProducerTemplate templatereportRoute;


public void saveDataFromExchange(Map<String, Object> DataMap){

    List<Map<String, Object>> paramList = new ArrayList<Map<String, Object>>();
    
    List<Map<String, Object>> rows = templatereportRoute.requestBody("direct:reportReport", DataMap, List.class);
<from uri="direct:reportRoute"/>

 <log message="  - ${body}"  loggingLevel="INFO"/>    

<setProperty propertyName="DataMap">
  <simple>${body}</simple>
</setProperty>


Solution 1:[1]

The error you encounter means that you are sending to a direct endpoint that does not exist in the Camel Context.

Since you posted an XML fragment that defines the route in question there are two possible problems (as already commented by @claus-ibsen):

  • The XML you posted is not in use. You are starting a Camel Context but it does not use your XML code. Are you using Spring? Then you can define your Camel routes in Spring XML.
  • Your setup is fine but your Java code sends the message too early, i.e. before the direct endpoint is up and running. You can put this code in a Test class and run it after the Camel context is started and ready.

Solution 2:[2]

Try put in public class from routerBuilder implemention the anotation @Component from Spring context

Ex:

@Component //<<<<---- This
public class RouterClass extends RouteBuilder {

    @Override
    public void configure() throws Exception {

    }
}//class closure

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 burki
Solution 2 Andrew Brown