分割后从骆驼路线获取原始消息

问题描述 投票:0回答:1

我有一条骆驼路线,该路线从队列中批量读取消息,处理该消息,然后继续将它们逐一发送到api,并等待api响应。

当抛出500响应时,我在检索开始时收到的原始消息时遇到问题。

我以为拆分器返回了原始消息?

这是我的路线:

    from(gatewayRouteConfig.getInputQueueEndpoint())
            .process(process1)
            .process(process2)
            .setExchangePattern(ExchangePattern.InOnly)
            .choice()
            .when().jsonpath("Message", true)
            .setBody(MESSAGE_WRAPPER_EXTRACTOR)
            .end()
            .split().method(messageSplitter, "splitMessages")
            .log(INFO, "Received Message : ${body}")
            .process(process3)
            .process(validate)
            .process(identity)
            .process(requestProcessor) //where the exception is thrown and the original message that is used in the exception handler is picking up
            .process(someService::gatewayResponseTimeStop)
            .process(someService::endToEndResponseStop)
            .process(someService::markGatewayDeliveryAsSuccess)
            .log("Completed processing...");

这是我在同一个类中的异常处理程序:

    private void configureExceptionHandlers() {

        onException(ProviderException.class) //thrown when 500 error occurs
            .useOriginalMessage() //picks message in the form the process(requestProcessor) method recieves it instead of start of route
            .handled(true)
            .log(ERROR, LOGGER, EXCEPTION_MESSAGE_WITH_STACKTRACE)
            .to(DLQ);
java spring apache-camel message-queue spring-camel
1个回答
0
投票

通过添加shareUnitOfWork解决]

.split().method(activityMessageSplitter, "splitActivityMessages").shareUnitOfWork()
© www.soinside.com 2019 - 2024. All rights reserved.