No consumers available on endpoint: Endpoint[direct://LookUpRoute]
Asked Answered
F

2

9

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>
Frontwards answered 28/9, 2019 at 15:45 Comment(3)
You are sending to an endpoint called "direct:createReport" yet you dont have one declared in the xml document. The end point in the xml is direct:reportRoute. direct:reportRoute != direct:createReportMatterhorn
sorry it was actually typed here wrongly but I'm sending it to List<Map<String, Object>> rows = templatereportRoute.requestBody("direct:reportRoute", DataMap, List.class);Frontwards
How do you run this? It sounds like the XML is not in use, and only the Java. You need to provide more details. As the XML part should be in use and started by Camel before the Java code that sends the message.Notebook
L
3

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.
Lush answered 30/9, 2019 at 6:21 Comment(0)
A
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
Activate answered 21/4, 2022 at 13:59 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Uniform

© 2022 - 2024 — McMap. All rights reserved.