SpringCloud学习第三天 舱壁隔板 BulkHead(信号量舱壁)与FixedThreadPoolBulkHead(固定线程池舱壁)

149 阅读1分钟

舱壁的主要作用就是控制并发、多个请求过来超过设置并发数量会触发兜底方法或者阻塞,控制同一时间的请求数量保证系统稳定

舱壁分为BulkHead(信号量舱壁)和FixedThreadPoolBulkHead(固定线程池舱壁)

SpringCloud整合BulkHead(信号量舱壁)

1、导入坐标

<!--BulkHead舱壁-->  
<dependency>  
    <groupId>io.github.resilience4j</groupId>  
    <artifactId>resilience4j-bulkhead</artifactId>  
</dependency>

2、yml配置BulkHead

image.png

3、创建controller调用中间模块的api image.png

SpringCloud整合FixedThreadPoolBulkHead(固定线程池舱壁)

1、导入坐标

<!--BulkHead舱壁-->  
<dependency>  
    <groupId>io.github.resilience4j</groupId>  
    <artifactId>resilience4j-bulkhead</artifactId>  
</dependency>

2、yml配置BulkHead

image.png 3、创建controller调用中间模块api

image.png