I want to implement retry mechanism along with circuit breaker in spring cloud gateway. Currently when I add Circuit Breaker filter alone to the spring cloud gateway, it works fine. And if I add Retry filter alone, it also works fine. But I want the request to be retried atleast 3 times automatically before the circuit changes to open state. Is there any way that I can integrate both retry and circuit breaker filter and make it work.
The flow of request will be: User Request -> Spring Cloud Gateway -> Microservice
Sample spring cloud gateway configuration will be like:
application.yml
spring:
cloud:
gateway:
routes:
- id: msOne
uri: http://localhost:8081/
predicates:
- Path=/ms-one-services/**
filters:
- RewritePath=/ms-one-services(?<segment>/?.*), $\{segment}
- name: CircuitBreaker
args:
name: msOneServices
fallbackUri: forward:/ms-one-services-fallback
- name: Retry
args:
name: msOneServices
retries: 3
statuses: BAD_GATEWAY
backoff:
firstBackOff: 5s
maxBackOff: 20s
factor: 2
basedOnPreviousValue: false