0

我正在使用具有响应式方法的 Spring Cloud 功能的 Spring Cloud Stream。我的活页夹是 RabbitMQ。根据定义 maxAttempts 属性是可以处理消息的次数(这就是我的解释)来自:https ://cloud.spring.io/spring-cloud-static/spring-cloud-stream/3.0.6.RELEASE /reference/html/spring-cloud-stream.html#_consumer_properties

maxAttempts:如果处理失败,尝试处理消息的次数(包括第一次)。设置为 1 以禁用重试。默认值:3。

问题是我的应用程序使用这个(默认)配置总是处理消息 4 次。现在我想禁用重试,所以我设置 max-attempts=1 并且消息总是被处理 2 次。我已经尝试设置spring.cloud.stream.rabbit.bindings.input.consumer.requeue-rejected=false虽然是默认设置。

关于如何让我的消息只处理一次的任何线索?

谢谢。

4

1 回答 1

0

Hoxton.SR1 很老了

我明白为什么用这些版本重试了;我将您的示例更新为最新版本,现在仅交付一次...

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>retry-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>retry-demo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>11</java.version>
        <spring-cloud.version>Hoxton.SR8</spring-cloud.version>
    </properties>

我不知道它是在哪个版本中修复的。

于 2020-09-11T16:04:04.200 回答