当前位置: 首页 > news >正文

springboot feign-httpclient 连接池配置

在默认情况下 spring cloud feign 在进行各个子服务之间的调用时,http组件使用的是jdk的HttpURLConnection,没有使用线程池。有2种可选的线程池:HttpClient 和 OKHttp

在Spring Boot项目中使用Feign并配置HttpClient连接池,你需要在application.propertiesapplication.yml文件中添加相关配置。

以下是application.properties中的配置示例:

# 设置Feign使用HttpClient
feign.httpclient.enabled=true# 设置HttpClient的连接管理器参数
feign.httpclient.max-connections=100
feign.httpclient.max-connections-per-route=20

或者,如果你使用的是application.yml,配置如下:

feign:httpclient:enabled: truemax-connections: 100max-connections-per-route: 20

feign:okhttp:enabled: true# feign最大连接数max-connections: 200# feign单个路径的最大连接数max-connections-per-route: 50

 

 确保你的项目中已经添加了Feign和HttpClient的依赖:

<!-- Feign客户端依赖 -->
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency><!-- HttpClient依赖 -->
<dependency><groupId>io.github.openfeign</groupId><artifactId>feign-httpclient</artifactId>
</dependency>

或者 

<dependency><groupId>io.github.openfeign</groupId><artifactId>feign-okhttp</artifactId><version>11.0</version>
</dependency>

http://www.lryc.cn/news/458383.html

相关文章:

  • 电汽车充电革命:充电桩的过去现在与未来
  • windows server 2019中安装.net framework 3.5功能出错
  • vscode gitlens收费破解
  • IPv 4
  • SQL 注入漏洞 - 学习手册
  • AVLTree 旋转笔记(根据平衡因子插入的公式,贼好理解)
  • STM32(十八):SPI通信
  • Redis持久化机制(RDBAOF详解)
  • 蛋白质结构中pdbx_strand_id和entity_id相互转化
  • 【父子线程传值TransmittableThreadLocal使用踩坑-及相关知识拓展】
  • 03 快乐树
  • springboot+react实现移动端相册(上传图片到oss/ 批量删除/ 查看图片详情等功能)
  • Python、R语言Lasso、Ridge岭回归、XGBoost分析Airbnb房屋数据:旅游市场差异、价格预测|数据分享...
  • Spring Boot驱动的交互式作业管理系统:师生共评功能实现
  • 基于SSM的旅游网站【附源码】
  • Python实现将目标文本批量存入Word,并将文本段落的开头进行缩进处理(11)
  • el-select 下拉框选项文字过长解决方案
  • C语言基础语法——类型转换
  • 来电无通话界面问题分析
  • 物理学基础精解【70】
  • HCIP--以太网交换安全(三)MAC地址漂移防止与检测
  • CSS3--美若天仙!?
  • 详细版的Jsoncpp的使用,包括在VS环境下配置
  • 开发指南070-3d模型
  • 问卷调查毕设计算机毕业设计投票系统SpringBootSSM框架
  • JavaWeb三大组件之Servlet
  • C++设计模式学习详解(23种)
  • Matlab中实现类属性仅在首次创建类实例时初始化
  • FLINK SQL动态表连续查询
  • C++ | Leetcode C++题解之第468题验证IP地址