Search code examples
spring-cloudspring-cloud-streamspring-rabbitspring-retryspring-cloud-function

Spring Cloud Stream disable retry


I'm using Spring cloud stream with spring cloud function with reactive approach. My binder is RabbitMQ. By definition maxAttempts property is the number of times that a message can be processed (that's what I interpret) From: https://cloud.spring.io/spring-cloud-static/spring-cloud-stream/3.0.6.RELEASE/reference/html/spring-cloud-stream.html#_consumer_properties

maxAttempts: If processing fails, the number of attempts to process the message (including the first). Set to 1 to disable retry. Default: 3.

The problem is my application with this (default) configuration always processed the message 4 times. And now I want to disable the retry, so I set max-attempts=1 and the message is always processed 2 times. I have already tried to set spring.cloud.stream.rabbit.bindings.input.consumer.requeue-rejected=false although is the default.

Any clue on how can I get my message processed just once?

Thanks.


Solution

  • Hoxton.SR1 is very old

    I can see why it was retried with those versions; I updated your example to the latest versions and it is only delivered once now...

        <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>
    

    I don't know which version it was fixed in.