springcloud:3.7测试线程池服务隔离

 

服务提供者【test-provider8001】

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

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

相关接口

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

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

 Openfeign远程调用消费者搭建

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

依赖

 <!-- 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

resilience4j:        
  #线程池隔离
  thread-pool-bulkhead:
    instances:
      # 实例名称:自己定义的名称,对应@Bulkhead的name
      backendA:
        # 最大线程池大小
        maxThreadPoolSize: 4
        # 核心线程池大小
        coreThreadPoolSize: 2
        #  队列容量
        queueCapacity: 2

OrderController【控制层】

/**
     * 测试线程池服务隔离
     *
     * @return
     */
    @GetMapping("/thread")
    @Bulkhead(name = "backendA", type = Bulkhead.Type.THREADPOOL)
    //name:对应的配置名,type:隔离类型-信号量/线程
    public CompletableFuture future() {
        log.info("********** 进入方法 *******");
        try {
            TimeUnit.SECONDS.sleep(5);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("********** 离开方法 *******");
        //需要异步调用
        return CompletableFuture.supplyAsync(() -> "线程池隔离信息......");
    }

相关接口

测试线程池隔离:http://localhost:8004/order/thread

jmeter测试思路

配置文件设置核心线程2个最大4个服务会一次处理4个请求 

  • 9
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

月木@

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值