Camel Direct Endpoint Exception

I have a simple problem. I cannot read from the endpoint of the file to the direct endpoint. Below is the code snippet:

public class SampleTwo {


public static void main(String[] args) throws Exception {
    final CamelContext camelContext = new DefaultCamelContext();
    camelContext.start();
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {          
            from("file://target/inbox?noop=true&fileName=test.csv").to("direct://start"); //Fails with "No consumers available on endpoint" exception
            //from("file://target/inbox?noop=true&fileName=test.csv").to("file://target/outbox"); //Works

        }
    });

    Thread.sleep(1000*6000);

    // stop the CamelContext
  //  camelContext.stop();
}}

      

I get a "There are no consumers on the endpoint" exception. It's simple routing and I did the best I could - now I've been over 10 hours :(

Please help ... following the stack trace (Trace enabled)

[hread #0 - file://target/inbox] EventHelper
TRACE Notifier: org.apache.camel.impl.DefaultRuntimeEndpointRegistry@99e74a is not enabled for the event: ID-01HW466539-57567-1431438054047-0-41 exchange failure: Exchange[test.csv] 
cause 
org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint: Endpoint[direct://start]. Exchange[test.csv]
[hread #0 - file://target/inbox] FileConsumer                   
TRACE Done processing file: GenericFile[test.csv] synchronously
[hread #0 - file://target/inbox] DefaultErrorHandler            
ERROR Failed delivery for (MessageId: ID-01HW466539-57567-1431438054047-0-42 on ExchangeId: ID-01HW466539-57567-1431438054047-0-41). Exhausted after delivery attempt: 
1 caught:
org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint: Endpoint[direct://start]. Exchange[test.csv]

      

Message history

--------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                              Elapsed (ms)
[route1            ] [route1            ] [file://target/inbox?fileName=test.csv&noop=true                               ] [         3]
[route1            ] [to1               ] [direct://start                                                                ] [         0]

      

Exchange

---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
Id                  ID-01HW466539-57567-1431438054047-0-41
ExchangePattern     InOnly
Headers             {breadcrumbId=ID-01HW466539-57567-1431438054047-0-42, CamelFileAbsolute=false, CamelFileAbsolutePath=C:\folder\eclipse-ws-march\camelsampletwo\target\inbox\test.csv, CamelFileContentType=null, CamelFileLastModified=1431426831841, CamelFileLength=45, CamelFileName=test.csv, CamelFileNameConsumed=test.csv, CamelFileNameOnly=test.csv, CamelFileParent=target\inbox, CamelFilePath=target\inbox\test.csv, CamelFileRelativePath=test.csv, CamelRedelivered=false, CamelRedeliveryCounter=0}
BodyType            org.apache.camel.component.file.GenericFile
Body                [Body is file based: GenericFile[test.csv]]]

      

StackTrace

---------------------------------------------------------------------------------------------------------------------------------------
org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint: Endpoint[direct://start]. Exchange[test.csv]

      

+3


source to share


4 answers


By default, a component direct

expects a corresponding consumer for each producer. Note the new config option failIfNoConsumers

shown in the Camel Documentation . Without a consumer, exchange has nowhere to go at the end of your route. You might consider adding another route as follows:



public class SampleTwo {


public static void main(String[] args) throws Exception {
    final CamelContext camelContext = new DefaultCamelContext();
    camelContext.start();
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {          
            from("file://target/inbox?noop=true&fileName=test.csv").to("direct://start"); 
            from("direct://start").to("file://target/outbox");  //ADDED

        }
    });

    Thread.sleep(1000*6000);
}}

      

+7


source


This is an exception

org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint: Endpoint[direct://XXXXX

      

also gets thrown when you forget to start your Camel context and create Producer / Consumer templates like I did ....



Got me half a day to find out :-( so don't forget

context.start()

      

+4


source


Why are you passing it on to direct? If you don't have direct clients? May I know an example of use?

You can even add a log endpoint after the endpoint and complete the route.

0


source


If you have multiple camelContext and did not supply the correct camelContext ID, you will get this exception as well.

0


source







All Articles