Camel onCompletion with modeBeforeConsumer - >的StackOverflowError

时间:2017-04-12 12:15:08

标签: apache-camel

我创建了一个如下所示的路线:

from("cxfrs:bean:server?bindingStyle=SimpleConsumer")
    .setExchangePattern(ExchangePattern.InOnly)
    .streamCaching()
    .onCompletion()
        .modeBeforeConsumer() // <-- Problem
        .to(CommonRoutes.ENDPOINT_DIRECT_LOGGING)
        .process(createResponse)
    .end()
    .split().body().stopOnException()
    .process(domainWrapProcessor)
    .to(OutAmq.OUT_PLUG)
;

记录路线是这样的:

from(ENDPOINT_DIRECT_LOGGING)
    .routeId(routeId_direct_logging)
    .doTry()
        .process(createAuditMessageProcessor)
        .marshal().json(JsonLibrary.Jackson)
        .to(ENDPOINT_VM_LOG_DELIVERY) //mocked out in Test
    .doCatch(Throwable.class)
        .process(e -> {
            log.warn("Failed to send audit message", e);
        })
    .end()
.end();

因为我只想将状态为空的身体发送给来电者,我将.process(createResponse).modeBeforeConsumer()一起添加。对于记录,如果在消费者之前或之后发生这种情况则无关紧要。 问题是添加.modeBeforeConsumer() camel会产生StackoverflowError。 onCompletion被触发了几百次,但是在.to(CommonRoutes.ENDPOINT_DIRECT_LOGGING) - createResponse永远不会到达之后总是反馈交换。但mock:ENDPOINT_VM_LOG_DELIVERY注册了数百个交换。 我找到了2个解决方法(但都破坏了所需的语义):

  • “mock and skip”ENDPOINT_DIRECT_LOGGING(未调用日志路径)
  • 删除/评论.modeBeforeConsumer()

那么这里发生了什么?可能导致这种情况的原因是什么?

这是骆驼错误日志(重复多次):

[immobilenserviceIn] [to3               ] [direct:logging                                                                ] [       769]
[routeId_directLogg] [doTry1            ] [doTry                                                                         ] [        12]
[routeId_directLogg] [process1          ] [Processor@0x11f0a5a1                                                          ] [         0]
[routeId_directLogg] [marshal1          ] [marshal[org.apache.camel.model.dataformat.JsonDataFormat@20435c40]            ] [        12]
[routeId_directLogg] [to1               ] [vm:log-delivery                                                               ] [         0]
[immobilenserviceIn] [process3          ] [Processor@0x142269f2                                                          ] [         0]
[immobilenserviceIn] [to3               ] [direct:logging                                                                ] [       757]
[routeId_directLogg] [doTry1            ] [doTry                                                                         ] [        12]

这是堆栈跟踪的一部分(直到第一次重复):

org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-D624342-61550-1491998476554-0-2]
    at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1706)
    at org.apache.camel.impl.DefaultExchange.setException(DefaultExchange.java:348)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:160)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)
    at org.apache.camel.processor.OnCompletionProcessor.doProcess(OnCompletionProcessor.java:151)
    at org.apache.camel.processor.OnCompletionProcessor$OnCompletionSynchronizationBeforeConsumer.onAfterRoute(OnCompletionProcessor.java:350)
    at org.apache.camel.util.UnitOfWorkHelper.afterRouteSynchronizations(UnitOfWorkHelper.java:154)
    at org.apache.camel.impl.DefaultUnitOfWork.afterRoute(DefaultUnitOfWork.java:273)
    at org.apache.camel.processor.CamelInternalProcessor$RouteLifecycleAdvice.after(CamelInternalProcessor.java:316)
    at org.apache.camel.processor.CamelInternalProcessor$InternalCallback.done(CamelInternalProcessor.java:245)
    at org.apache.camel.processor.CamelInternalProcessor$InternalCallback.done(CamelInternalProcessor.java:256)
    at org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:86)
    at org.apache.camel.processor.TryProcessor.process(TryProcessor.java:101)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)
    at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)

0 个答案:

没有答案