Reputation: 63
I am having a simple problem. I am not able to read from a file end-point into a direct end-point. 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 an exception "No consumers available on endpoint". It's a simple routing & I have done all I could -spent more than 10hours now :(
Please help ... following as 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]
Upvotes: 6
Views: 19553
Reputation: 11
If you have multiple camelContext and you have not mentioned correct camelContext id then also you will get this exception.
Upvotes: 0
Reputation: 903
Why you are passing it to a direct ? If you don't have any consumers on direct ? May I know the use case ?
You can even just add a log endpoint after from endpoint and terminate the route .
Upvotes: 0
Reputation: 286
This Exception
org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint: Endpoint[direct://XXXXX
is also thrown when you forget to start your Camel context and create Producer/Consumer templates, like me....
Took me half a day to find out :-(, so don't forget
context.start()
Upvotes: 5
Reputation:
By default, the direct
component expects that there is a matching consumer for every producer. Note the new configuration option failIfNoConsumers
shown in the Camel Documentation. Without a consumer, the exchange has nowhere to go at the end of your route. You may consider adding another route like this:
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);
}}
Upvotes: 11