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]
The direct: component provides direct, synchronous invocation of any consumers when a producer sends a message exchange. This endpoint can be used to connect existing routes in the same camel context.
Using onException to handle known exceptions is a very powerful feature in Camel. You can mark the exception as being handled with the handle DSL, so the caller will not receive the caused exception as a response. The handle is a Predicate that is overloaded to accept three types of parameters: Boolean.
If you configure the Dead Letter Channel to use maximumRedeliveries = -1 then Camel will retry forever. When you consume a message you can check the in message header org. apache.
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);
}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With