Camel Direct端点异常

kee*_*irl 4 java apache-camel

我有一个简单的问题.我无法从文件端点读取到直接端点.以下是代码段:

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();
}}
Run Code Online (Sandbox Code Playgroud)

我得到一个例外"端点上没有可用的消费者".这是一个简单的路由&我已经做了所有我可以 - 现在超过10小时:(

请帮助......跟踪堆栈跟踪(启用跟踪)

[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]
Run Code Online (Sandbox Code Playgroud)

消息历史

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

交换

---------------------------------------------------------------------------------------------------------------------------------------
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]]]
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪

---------------------------------------------------------------------------------------------------------------------------------------
org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint: Endpoint[direct://start]. Exchange[test.csv]
Run Code Online (Sandbox Code Playgroud)

Ada*_*kes 10

默认情况下,direct组件期望每个生产者都有匹配的使用者.请注意Camel文档中failIfNoConsumers显示的新配置选项.没有消费者,交易所无处可去.你可以考虑添加另一条这样的路线:

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);
}}
Run Code Online (Sandbox Code Playgroud)


小智 5

此例外

org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint: Endpoint[direct://XXXXX
Run Code Online (Sandbox Code Playgroud)

当您忘记启动骆驼上下文并创建像我一样的Producer / Consumer模板时,也会引发该错误。

花了我半天时间找出:-(,所以别忘了

context.start()
Run Code Online (Sandbox Code Playgroud)