【问题标题】:How to turn off automatic retry in Spring Integration Jms.inboundGateway如何在 Spring Integration Jms.inboundGateway 中关闭自动重试
【发布时间】:2016-08-05 08:21:01
【问题描述】:

我正在使用 spring 4.2.4.RELEASEspring-integration-java-dsl:1.1.2.RELEASE

我有Jms.inboundGateway 和一些变压器。当转换器失败转换消息时,入站网关一次又一次地重试。但是我想在出现异常时停止整个流程。
有可能吗?

这是我的流程配置:

@Bean
public IntegrationFlow nonStop {
    return IntegrationFlows
            .from(Jms.inboundGateway(emsConnectionFactory)
                    .destination(myDestination)
                    .configureListenerContainer(spec -> spec
                            .sessionTransacted(true)
                            .subscriptionDurable(true)
                            .durableSubscriptionName(durableSubscriptionName)
                            .errorHandler((ErrorHandler) t -> {
                                t.printStackTrace();
                                throw new RuntimeException(t);
                            }))
                    .errorChannel(errorChannel)
                    .autoStartup(true)
                    .id(myNonStoppableFlow))
            .filter(...)
            .transform(...)
            .handle(Jms.outboundAdapter(emsConnectionFactory)
                             .destination(myOnotherDestination))
            .get();
}

一个有趣的通知。当errorHandler 吞下异常时,入站网关立即退出。当它抛出运行时异常时,会有大约 5 秒的延迟(未在任何地方配置)。

【问题讨论】:

    标签: spring-integration dsl spring-java-config


    【解决方案1】:

    JMS 中的 retry 被称为 redelivery: http://www.javaworld.com/article/2074123/java-web-development/transaction-and-redelivery-in-jms.html

    因此,任何下游异常都会导致您的消息回滚和重新传递,可以在 Broker 上为目标配置。

    实际上,如果您的.errorChannel(errorChannel) 流没有重新抛出异常,它将被视为successful 处理和提交。

    如果你真的需要Jms.inboundGateway(),你应该重新考虑一下。因为这需要一个回复,而你的Jms.outboundAdapter() 最终看起来是不可能的。

    【讨论】:

      猜你喜欢
      • 2014-02-17
      • 1970-01-01
      • 2023-03-27
      • 2015-07-07
      • 1970-01-01
      • 2022-10-18
      • 2022-10-24
      • 2014-12-11
      • 2015-11-06
      相关资源
      最近更新 更多