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个线程进行测试

相关推荐
uzong3 小时前
后端线上发布计划模板
后端
uzong4 小时前
软件工程师应该关注的几种 UML 图
后端
heartbeat..4 小时前
Spring AOP 全面详解(通俗易懂 + 核心知识点 + 完整案例)
java·数据库·spring·aop
Jing_jing_X4 小时前
AI分析不同阶层思维 二:Spring 的事务在什么情况下会失效?
java·spring·架构·提升·薪资
上进小菜猪5 小时前
基于 YOLOv8 的 100 类中药材智能识别实战 [目标检测完整源码]
后端
码事漫谈6 小时前
AI 技能工程入门:从独立能力到协作生态
后端
码事漫谈6 小时前
构建高并发AI服务网关:C++与gRPC的工程实践
后端
myzshare7 小时前
实战分享:我是如何用SSM框架开发出一个完整项目的
java·mysql·spring cloud·微信小程序
颜酱8 小时前
前端必备动态规划的10道经典题目
前端·后端·算法
程序猿零零漆8 小时前
Spring之旅 - 记录学习 Spring 框架的过程和经验(十一)基于XML方式、注解的声明式事务控制、Spring整合Web环境
xml·学习·spring