netty之ConnectionProvider类型elastic和fixed区别
发布日期:2021-06-30 21:31:32
浏览次数:2
分类:技术文章
本文共 1531 字,大约阅读时间需要 5 分钟。
在Netty中存在四种创建连接的方式:
- newConnection:每次都是新链接
- elastic:弹性连接池
static ConnectionProvider elastic(String name, @Nullable Duration maxIdleTime, @Nullable Duration maxLifeTime) { return builder(name).maxConnections(Integer.MAX_VALUE) .pendingAcquireTimeout(Duration.ofMillis(0)) .pendingAcquireMaxCount(-1) .maxIdleTime(maxIdleTime) .maxLifeTime(maxLifeTime) .build(); }
- fixed:固定连接池
static ConnectionProvider fixed(String name, int maxConnections, long acquireTimeout, @Nullable Duration maxIdleTime, @Nullable Duration maxLifeTime) { if (maxConnections == -1) { return elastic(name, maxIdleTime, maxLifeTime); } if (acquireTimeout < 0) { throw new IllegalArgumentException("Acquire Timeout value must be positive"); } return builder(name).maxConnections(maxConnections) .pendingAcquireMaxCount(-1) // keep the backwards compatibility .pendingAcquireTimeout(Duration.ofMillis(acquireTimeout)) .maxIdleTime(maxIdleTime) .maxLifeTime(maxLifeTime) .build(); }
- builder:自定义连接池,通过bulider模式设置参数
builder(name).maxConnections(maxConnections) .pendingAcquireMaxCount(-1) // keep the backwards compatibility .pendingAcquireTimeout(Duration.ofMillis(acquireTimeout)) .maxIdleTime(maxIdleTime) .maxLifeTime(maxLifeTime) .build();
转载地址:https://lizz6.blog.csdn.net/article/details/109602933 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年04月26日 11时13分30秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
基础架构系列篇-系统centos7安装docker+COMPOSE
2021-07-03
基础架构系列篇-NGINX部署VUE
2021-07-03
个人电商项目,基于uni-app+ springcloud +VUE技术
2021-07-03
基础架构系列篇-系统centos7安装kafka
2021-07-03
基础架构系列篇-系统centos7中docker安装分布式文件存储服务minio
2021-07-03
知识点记录-java判断系统是linux或windows
2021-07-03
知识点记录-springboot静态资源映射路径
2021-07-03
微服务springcloud2系列篇-配置与注册nacos组件
2021-07-03
用户权限设计-基于RBAC模型
2021-07-03
微服务springcloud2系列篇-网关GATEWAY跨域问题
2021-07-03
软件质量的8个特性
2021-07-03
应届渣渣前端的艰难求职之路
2021-07-03
2021年不可错过的17种JS优化技巧(一)
2021-07-03
月薪15~20k的前端面试问什么?
2021-07-03
在 Vue 中用 Axios 异步请求API
2021-07-03
MYSQL——事务操作+视图+存储引擎
2021-07-03
MySQL进阶查询(SELECT 语句高级用法)
2021-07-03
Mysql 之主从复制
2021-07-03
【NLP学习笔记】知识图谱阅读笔记及其心得
2021-07-03
【工具使用】新版CSDN-markdown编辑器使用指南
2021-07-03