Bulkhead pattern supporting

如果类路径上有 resilience4j-bulkhead,Spring Cloud CircuitBreaker 将用 Resilience4j Bulkhead 包装所有方法。你可以通过将 spring.cloud.circuitbreaker.bulkhead.resilience4j.enabled 设置为 false 来禁用 Resilience4j Bulkhead。

If resilience4j-bulkhead is on the classpath, Spring Cloud CircuitBreaker will wrap all methods with a Resilience4j Bulkhead. You can disable the Resilience4j Bulkhead by setting spring.cloud.circuitbreaker.bulkhead.resilience4j.enabled to false.

Spring Cloud CircuitBreaker Resilience4j 提供了两种舱壁模式实现:

Spring Cloud CircuitBreaker Resilience4j provides two implementation of bulkhead pattern:

  • a SemaphoreBulkhead which uses Semaphores

  • a FixedThreadPoolBulkhead which uses a bounded queue and a fixed thread pool.

默认情况下,Spring Cloud CircuitBreaker Resilience4j 使用 FixedThreadPoolBulkhead。要修改默认行为以使用 SemaphoreBulkhead,请将属性 spring.cloud.circuitbreaker.resilience4j.enableSemaphoreDefaultBulkhead 设置为 true

By default, Spring Cloud CircuitBreaker Resilience4j uses FixedThreadPoolBulkhead. To modify the default behavior to use SemaphoreBulkhead set the property spring.cloud.circuitbreaker.resilience4j.enableSemaphoreDefaultBulkhead to true.

有关舱壁模式实现的更多信息,请参见 Resilience4j Bulkhead

For more information on implementation of Bulkhead patterns see the Resilience4j Bulkhead.

Customizer<Resilience4jBulkheadProvider> 可用于提供默认 BulkheadThreadPoolBulkhead 配置。

The Customizer<Resilience4jBulkheadProvider> can be used to provide a default Bulkhead and ThreadPoolBulkhead configuration.

@Bean
public Customizer<Resilience4jBulkheadProvider> defaultBulkheadCustomizer() {
    return provider -> provider.configureDefault(id -> new Resilience4jBulkheadConfigurationBuilder()
        .bulkheadConfig(BulkheadConfig.custom().maxConcurrentCalls(4).build())
        .threadPoolBulkheadConfig(ThreadPoolBulkheadConfig.custom().coreThreadPoolSize(1).maxThreadPoolSize(1).build())
        .build()
);
}