springcloud:3.6测试信号量隔离

服务提供者【test-provider8001】

Openfeign远程调用服务提供者搭建

文章地址http://t.csdnimg.cn/06iz8

相关接口

测试远程调用:http://localhost:8001/payment/index

服务消费者【test-consumer-resilience4j8004】

Openfeign远程调用消费者搭建

文章地址http://t.csdnimg.cn/06iz8

依赖

java 复制代码
 <!-- resilience4j隔离依赖  -->
        <dependency>
            <groupId>io.github.resilience4j</groupId>
            <artifactId>resilience4j-bulkhead</artifactId>
            <version>1.7.0</version>
        </dependency>
        <!-- resilience4j  -->
        <dependency>
            <groupId>io.github.resilience4j</groupId>
            <artifactId>resilience4j-spring-cloud2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-circuitbreaker-resilience4j</artifactId>
        </dependency>

application.yml

java 复制代码
resilience4j:
  #信号量隔离
  bulkhead:
    instances:
      # 实例名称:自己定义的名称,对应@Bulkhead的name
      backendA:
        # 隔离允许并发线程执行的最大数量
        maxConcurrentCalls: 5
        # 当达到并发调用数量时,新的线程的阻塞时间
        maxWaitDuration: 20ms

OrderController【控制层】

java 复制代码
 /**
     * 测试信号量隔离
     *
     * @return
     */
    @GetMapping("/bulkhead")
    @Bulkhead(name = "backendA", type = Bulkhead.Type.SEMAPHORE)
    //name:对应的配置名,type:隔离类型-信号量/线程
    public String bulkhead() throws InterruptedException {
        log.info("************** 进入方法 *******");
        TimeUnit.SECONDS.sleep(10);
        String index = paymentFeignService.paymentIndex();
        log.info("************** 离开方法 *******");
        return index;
    }

相关接口

测试信号量隔离:http://localhost:8004/order/bulkhead

jmeter测试思路

此配置隔离并发线程最大数量为5,所以jmeter我们采用大于5个线程进行测试

相关推荐
qq_348231856 分钟前
Spring Boot 体系核心全解
java·spring boot·后端
shengjk18 分钟前
一文搞定 NTP 三大核心问题:是什么、为何不准、来自何方
后端
不会玩电脑的Xin.10 分钟前
Spring框架入门:IOC与AOP实战
java·后端·spring
SnrtIevg14 分钟前
Spring Modulith :构建模块化单体应用
后端
LSTM9719 分钟前
用 Python 自动化编辑 Word 文档
后端
摇滚侠22 分钟前
2025最新 SpringCloud 教程,接口测试,本地事务,打通链路,笔记65,笔记66,笔记67
笔记·spring·spring cloud
王中阳Go27 分钟前
手把手教你用 GoFrame 实现 RBAC 权限管理,从零到一搞定后台权限系统
后端
苏三说技术31 分钟前
try...catch真的影响性能吗?
后端
青梅主码38 分钟前
麦肯锡发布最新报告《职场超级代理:赋能人们释放 AI 的全部潜力》:如何用 AI 赋能员工,释放无限潜力?
后端
悟空码字1 小时前
SpringBoot实现日志系统,Bug现形记
java·spring boot·后端