简体   繁体   中英

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>

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

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 , ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM