【问题标题】:Spring integration org.springframework.integration.MessageTimeoutException handlingSpring集成org.springframework.integration.MessageTimeoutException处理
【发布时间】:2018-09-14 14:08:49
【问题描述】:

我有以下 spring 集成流程:

        @Bean
        public IntegrationFlow innerInFlow(@Value("${jms.concurrency:10}") String concurrency) {
            return IntegrationFlows
                    .from(Jms.messageDrivenChannelAdapter(
                            Jms.container(connectionFactory, innerQueue)
                                    .concurrency(concurrency)
                                    .taskExecutor(taskExecutor()).get())
                            .extractPayload(true))
                    .transform(Transformers.deserializer())
                    .route(eventRouter())
                    .get();
        }

路由之后

        @Bean
        public IntegrationFlow findPersonClienFlow(FindClientHandler findClientHandler) {
            return IntegrationFlows.from(findPersonClienChannel())
                    .transform(findClientHandler, "queryToFindClientRequest")
                    .handle(Jms.outboundGateway(connectionFactory).requestDestination(cifRequestQueue)
                            .replyDestination(cifResponseQueue).get())
                    .get();
        }

    }

Jms.outboundGateway 中我有org.springframework.integration.MessageTimeoutException,但我无法理解如何处理此错误?

谢谢。

【问题讨论】:

    标签: spring-integration spring-jms spring-integration-dsl


    【解决方案1】:

    我相信MessageTimeoutException 存在是因为对方没有回复你到cifResponseQueue

    您可以在那里配置receiveTimeout(),但无论如何默认为5 secs

    您还可以在此Jms.outboundGateway() 上配置RequestHandlerRetryAdviceExpressionEvaluatingRequestHandlerAdvice,以使用ConsumerEndpointSpecadvice(...) 以某种特定方式真正处理此异常。

    请参阅有关此事的文档:https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints-chapter.html#message-handler-advice-chain

    更新

    此外,正如 Gary 指出的,您可以使用 Jms.messageDrivenChannelAdapter() 级别的 errorChannel() 和订阅此频道的一些流来捕获异常。

    【讨论】:

    • 真的有问题吗?它是框架,它必须有解决这个常规问题的工具。还是我什么都不懂?
    • 您可以将errorChannel 添加到messageDrivenChannelAdapter 并处理来自该通道的流上的错误。
    • 我该怎么做?
    • 框架无法假设该异常的真正作用是什么,但它为您提供了大量工具来在每种情况下做出正确的选择。
    猜你喜欢
    • 1970-01-01
    • 2011-05-13
    • 1970-01-01
    • 1970-01-01
    • 2015-05-24
    • 2018-07-05
    • 2015-10-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多