최대 1 분 소요

add dependency

  • dependency library 를 추가 ```xml
org.springframework.cloud spring-cloud-starter-circuitbreaker-reactor-resilience4j
- Declare circuit breaker in application.yaml

```yaml
spring:
  cloud:
    gateway:
      routes:
        - id: my_route
          uri: http://localhost:8060/
          filters:
            - name: CircuitBreaker
              args:
                name: myCircuitBreaker
                fallbackUri: forward:/inCaseOfFailure
  • Declare the endpoint which will be called in the case of failure (a connection error, for example)
    @RequestMapping("/inCaseOfFailure")
      public Mono<ResponseEntity<String>> inCaseOfFailureUseThis() {
          return Mono.just(ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).body("body for service failure case"));
    }
    

참고

댓글남기기