Skip to content

Add backoff support to Retry filter in Spring Cloud Gateway MVC (server-mvc) #4141

@tfactor2

Description

@tfactor2

The RetryFilterFunctions.RetryConfig class in the spring-cloud-gateway-server-webmvc module does not support backoff configuration, while the reactive (WebFlux) variant (RetryGatewayFilterFactory) does.

Current state

Neither of the two current MVC retry implementations supports backoff:

  • GatewayRetryFilterFunctions — Spring Retry-based, deprecated (Spring Retry is in maintenance-only mode)
  • FrameworkRetryFilterFunctions — Spring Framework retry-based, the new preferred path

Neither exposes a backoff option, and RetryConfig has no backoff field or setter.

This was previously noted with a // TODO: backoff comment in the old RetryFilterFunctions before the refactoring.

Expected behavior

RetryConfig should support backoff configuration equivalent to what the reactive module offers via RetryGatewayFilterFactory, e.g.:

.filter(retry(config -> {
    config.setRetries(3);
    config.setBackoff(Duration.ofMillis(100), Duration.ofMillis(500), 2, false);
}))

And YAML parity with the reactive module:

filters:
  - name: Retry
    args:
      retries: 3
      backoff:
        firstBackoff: 100ms
        maxBackoff: 500ms
        factor: 2
        basedOnPreviousValue: false

Version

spring-cloud-gateway-server-webmvcmain branch (post-refactoring to FrameworkRetryFilterFunctions)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions