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

相关推荐
Z.风止2 分钟前
Go-learning(1)
开发语言·笔记·后端·golang
光电大美美-见合八方中国芯5 分钟前
【SOA仿真6】多层膜仿真计算
后端·restful
小马爱打代码12 分钟前
Spring Boot:Sentinel 企业级熔断、降级与限流实战
spring boot·后端·sentinel
野犬寒鸦24 分钟前
从零起步学习并发编程 || 第二章:多线程与死锁在项目中的应用示例
java·开发语言·数据库·后端·学习
一起养小猫25 分钟前
Flutter for OpenHarmony 实战:打造功能完整的云笔记应用
网络·笔记·spring·flutter·json·harmonyos
没有腰的嘟嘟嘟26 分钟前
[特殊字符] 本地部署 Qwen3:4B 大模型并使用 Spring Boot 对接实践指南
spring·ai·spring ai
没有bug.的程序员29 分钟前
Spring Cloud Sentinel:熔断降级规则配置与分布式流量防线实战终极指南
java·分布式·后端·spring cloud·sentinel·熔断规则·分布式流量防线
JP-Destiny30 分钟前
后端-RabbitMQ
后端·消息队列·rabbitmq·java-rabbitmq
李慕婉学姐32 分钟前
【开题答辩过程】以《基于SpringBoot Vue的校园后勤管理系统设计与实现》为例,不知道这个选题怎么做的,不知道这个选题怎么开题答辩的可以进来看看
vue.js·spring boot·后端
梵得儿SHI37 分钟前
实战项目落地:微服务拆分原则(DDD 思想落地,用户 / 订单 / 商品 / 支付服务拆分实战)
spring cloud·微服务·云原生·架构·微服务拆分·ddd方法论·分布式数据一致性