This version is still in development and is not considered stable yet. For the latest stable version, please use Spring-Cloud-CircuitBreaker 3.1.3!spring-doc.cn

Circuit Breaker Properties Configuration

You can configure CircuitBreaker and TimeLimiter configs or instances in your application’s configuration properties file. Property configuration has higher priority than Java Customizer configuration.spring-doc.cn

Descending priority from top to bottom.spring-doc.cn

ReactiveResilience4JCircuitBreakerFactory.create(String id, String groupName)
Resilience4JCircuitBreakerFactory.create(String id, String groupName)

Global Default Properties Configuration

resilience4j.circuitbreaker:
    configs:
        default:
            registerHealthIndicator: true
            slidingWindowSize: 50

resilience4j.timelimiter:
    configs:
        default:
            timeoutDuration: 5s
            cancelRunningFuture: true

Configs Properties Configuration

resilience4j.circuitbreaker:
    configs:
        groupA:
            registerHealthIndicator: true
            slidingWindowSize: 200

resilience4j.timelimiter:
    configs:
        groupC:
            timeoutDuration: 3s
            cancelRunningFuture: true

Instances Properties Configuration

resilience4j.circuitbreaker:
 instances:
     backendA:
         registerHealthIndicator: true
         slidingWindowSize: 100
     backendB:
         registerHealthIndicator: true
         slidingWindowSize: 10
         permittedNumberOfCallsInHalfOpenState: 3
         slidingWindowType: TIME_BASED
         recordFailurePredicate: io.github.robwin.exception.RecordFailurePredicate

resilience4j.timelimiter:
 instances:
     backendA:
         timeoutDuration: 2s
         cancelRunningFuture: true
     backendB:
         timeoutDuration: 1s
         cancelRunningFuture: false
  • ReactiveResilience4JCircuitBreakerFactory.create("backendA") or Resilience4JCircuitBreakerFactory.create("backendA") will apply instances backendA propertiesspring-doc.cn

  • ReactiveResilience4JCircuitBreakerFactory.create("backendA", "groupA") or Resilience4JCircuitBreakerFactory.create("backendA", "groupA") will apply instances backendA propertiesspring-doc.cn

  • ReactiveResilience4JCircuitBreakerFactory.create("backendC") or Resilience4JCircuitBreakerFactory.create("backendC") will apply global default propertiesspring-doc.cn

  • ReactiveResilience4JCircuitBreakerFactory.create("backendC", "groupC") or Resilience4JCircuitBreakerFactory.create("backendC", "groupC") will apply global default CircuitBreaker properties and config groupC TimeLimiter propertiesspring-doc.cn

For more information on Resilience4j property configuration, see Resilience4J Spring Boot 2 Configuration.spring-doc.cn

Disabling the TimeLimiter

By default, the TimeLimiter is enabled and every execution is backed by a time limit. This time limit is either defined explicitly or the default time limit (provided by io.github.resilience4j.timelimiter.TimeLimiterConfig#ofDefaults) is used.spring-doc.cn

The TimeLimiter can be globally disabled by setting the property spring.cloud.circuitbreaker.resilience4j.disable-time-limiter to true.spring-doc.cn

spring:
	cloud:
		circuitbreaker:
			resilience4j:
				disable-time-limiter: true

TimeLimiter can also be disabled for specific group or instances using spring.cloud.circuitbreaker.resilience4j.disable-time-limiter-map as below:spring-doc.cn

spring:
	cloud:
		circuitbreaker:
			resilience4j:
				disable-time-limiter-map:
					group1: true
					instanceA: false
					instanceB: true

These options for disabling TimeLimit are provided within spring-cloud-circuitbreaker and applies to both basic and reactive circuitbreaker implementation.spring-doc.cn

Priority order of disabling is : instance > group > global. Based on above configuration, instanceB and group1 have TimeLimiter disabled but instanceA has enabled. For all other instances and groups, it will fall back to globally set value of spring.cloud.circuitbreaker.resilience4j.disable-time-limiter If spring.cloud.circuitbreaker.resilience4j.disable-time-limiter is not set, by default, TimeLimit is enabled for remaining circuitbreaker instances and groups.spring-doc.cn