【问题标题】:Camel Multicast Exception PropagationCamel 组播异常传播
【发布时间】:2016-06-24 02:34:25
【问题描述】:

在多播中抛出异常时,Camel 不会传播异常。

鉴于以下设置,direct:route 从其 beanRef 中抛出异常:

        rest("/...")
        .post()
        .consumes("application/json")
        .produces("application/json")
        .route()
            .onException(Exception.class)
                .handled(true)
                .bean("exceptionHandler")
                .marshal("exceptionDataFormat")
            .end()
            .unmarshal("dataFormat")
            ...
            .enrich("direct:services", new ServiceAggregator())
            .to("direct:anotherRoute")
            ...
        .end()
    .endRest();


    from("direct:services")
        .errorHandler(noErrorHandler())
        .multicast()
        .setAggregationStrategy(new GroupedExchangeAggregationStrategy())
        .executorServiceRef("executor")
        .parallelAggregate()
        .streaming()
        .stopOnException()
            .to("direct:route")
        .end()
    .end();

    from("direct:route")
        .errorHandler(noErrorHandler())
        .bean("someRef", "someMethod")
    .end();

我没有让异常处理程序消耗交换并处理错误,而是立即返回(到 SoapUI)以下异常:

org.apache.camel.CamelExchangeException: Parallel processing failed for number 0. Exchange[...] at org.apache.camel.processor.MulticastProcessor$1.call(MulticastProcessor.java:328)
at org.apache.camel.processor.MulticastProcessor$1.call(MulticastProcessor.java:299)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

并且父路由以该异常结束并且没有异常处理。

如果direct:anotherRoute 抛出异常,则该异常得到正确处理。

为什么我不能向父路由传播多播异常?

骆驼 2.17-SNAPSHOT

【问题讨论】:

    标签: apache-camel


    【解决方案1】:

    尝试使用

    .errorHandler(noErrorHandler()) 
    

    在将异常传播到onexception()的父子路由中

    【讨论】:

      【解决方案2】:

      打开多播上的shareUnitOfWork 选项。查看更多详细信息:http://camel.apache.org/multicast,并且有一个关于拆分器的示例,它也有这个选项:http://camel.apache.org/splitter.html

      【讨论】:

      • 试过这个解决方案,还是没有传播异常。使用骆驼2-18
      猜你喜欢
      • 2015-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多