springcloud config坑系列一之Connection pool shut down on "zuul.host.*" property change
在使用springcloud config自动刷新功能难免会踩到一些坑,下面来介绍下
在生成中经常需要动态刷新配置,只需要增加@RefreshScope,并且执行手动刷新链接/actuator/refresh,或者集成springcloudbus来自动刷新,但是有些配置动态刷新时需要实例化一些spring内部复杂的对象,这里就不能自动更新了,比如说zuul。
zuul路由配置可以自动刷新,
zuul:
sensitive-headers:
routes:
api-b:
path: /apib/**
serviceId: dataeyeServer
但是设计到zuul内部resttemplate的一些超时配置,如果改动了,并且手动刷新,则会出现标题中的错误Connection pool shut down on "zuul.host.*" property change
zuul:
host:
connect-timeout-millis: 10000
socket-timeout-millis: 600000
错误信息如下:
java.lang.IllegalStateException: Connection pool shut down
at org.apache.http.util.Asserts.check(Asserts.java:34) ~[httpcore-4.4.8.jar:4.4.8]
at org.apache.http.pool.AbstractConnPool.lease(AbstractConnPool.java:191) ~[httpcore-4.4.8.jar:4.4.8]
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.requestConnection(PoolingHttpClientConnectionManager.java:257) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:176) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) ~[httpclient-4.5.3.jar:4.5.3]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.3.jar:4.5.3]
at org.springframework.http.client.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:89) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:659) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:628) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:302) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]
这是由于自动刷新时,由于host中超时时间配置变更导致连接池先关闭,再准备重新创建,但是在重现创建的过程中却没有重新创建连接池,还是引用原有连接池导致报错。
解决方案一:将springcloud升级到Edgware.RELEASE,即
spring-cloud-commons-dependencies 版本升级到1.3.2.RELEASE
解决方案二:手动实例化连接池
参考资料
https://github.com/spring-cloud/spring-cloud-netflix/issues/3406
https://github.com/spring-cloud/spring-cloud-commons/issues/330
https://github.com/spring-cloud/spring-cloud-config/issues/918
springcloud config坑系列一之Connection pool shut down on "zuul.host.*" property change的更多相关文章
- java.lang.IllegalStateException: Connection pool shut down
最近使用HttpClient 4.5 使用 CloseableHttpClient 发起连接后,使用CloseableHttpResponse 接受返回结果,结果就报错了,上网查了下,有位stacko ...
- com.aliyun.oss.ClientException: Connection error due to: Connection pool shut down
com.aliyun.oss.ClientException: Connection error due to: Connection pool shut down[ErrorCode]: Unkno ...
- Can not find connection pool config file
暂时未解决 checkActivation=====================true Can Not Parse ConnectionCfg! 2019/10/12-11:23:38 > ...
- SpringCloud 源码系列(5)—— 负载均衡 Ribbon(下)
SpringCloud 源码系列(4)-- 负载均衡 Ribbon(上) SpringCloud 源码系列(5)-- 负载均衡 Ribbon(下) 五.Ribbon 核心接口 前面已经了解到 Ribb ...
- SpringCloud 源码系列(6)—— 声明式服务调用 Feign
SpringCloud 源码系列(1)-- 注册中心 Eureka(上) SpringCloud 源码系列(2)-- 注册中心 Eureka(中) SpringCloud 源码系列(3)-- 注册中心 ...
- springcloud情操陶冶-springcloud config server(三)
承接前文springcloud情操陶冶-springcloud config server(二),本文就不讲述server了,就简单阐述下client的应用 前话 config server在引入的时 ...
- SpringCloud 进阶之分布式配置中心(SpringCloud Config)
1. SpringCloud Config SpringCLoud Config 为微服务架构中的微服务提供集中化的外部配置支持,配置服务器为各个不同微服务应用 的所有环境提供了一个中心化的外部配置; ...
- 【爬坑系列】之kubernetes环境搭建:二进制安装与镜像安装
准备: 网上教如何编译与安装kubernetes的教程很多,需要提前准备的也很多,比如关闭selinux,防火墙啦....但有一点一定要注意,编译kubernetes源码时要求有2G内存,这个可是实打 ...
- springcloud Config 入门,带视频
疯狂创客圈 Java 高并发[ 亿级流量聊天室实战]实战系列 [博客园总入口 ] 架构师成长+面试必备之 高并发基础书籍 [Netty Zookeeper Redis 高并发实战 ] 前言 Crazy ...
- SpringCloud学习笔记(九):SpringCloud Config 分布式配置中心
概述 分布式系统面临的-配置问题 微服务意味着要将单体应用中的业务拆分成一个个子服务,每个服务的粒度相对较小,因此系统中会出现大量的服务.由于每个服务都需要必要的配置信息才能运行,所以一套集中式的.动 ...
随机推荐
- macOS Big Sur 11.0.1光盘镜像文件制作
https://blog.csdn.net/hymnal/article/details/110393501
- Scrcpy - 开源免费在电脑显示手机画面并控制手机的工具 (投屏/录屏/免Root)
教程:https://www.iplaysoft.com/scrcpy.html 官方地址:https://github.com/Genymobile/scrcpy
- 【HDC 2024】华为云开发者联盟驱动应用创新,赋能开发者成长
本文分享自华为云社区<[HDC 2025]华为云开发者联盟驱动应用创新,赋能开发者成长>,作者:华为云社区精选. 6月21日到23日,华为开发者大会(HDC 2024)于东莞松山湖举行,这 ...
- SDL3 入门(3):三角形
SDL3 提供了 SDL_RenderGeometry 函数绘制几何图形,用法和 OpenGL 差不多,先定义顶点数据,然后根据顶点数据绘制几何图形. 绘制三角形的代码如下: std::array&l ...
- Ubuntu 使用 SVN 管理 项目
背景 公司的项目需要在 Linux 环境进行开发,而都是使用 SVN 进行管理的.习惯了 SVN-GUI 的我,需要学习 SVN 的命令行. 准备 安装 SVN sudo apt-get apt-ge ...
- 【路径规划】OSQP曲线平滑 公式及代码
参考与前言 apollo 代码:https://github.com/ApolloAuto/apollo/tree/master/modules/planning/math/smoothing_spl ...
- node.js (原生模板引擎模板)
app01 // 引入http模块 const http = require('http'); //连接数据库 require('./model/connects'); // 创建网站服务器 cons ...
- 1.Javascript 快速入门(主要)
运算 &&运算是与运算,只有所有都为true,&&运算结果才是true: true && true; // 这个&&语句计算结果为tru ...
- Mybatis ResultMap复杂对象一对一查询结果映射之association
Mybatis复杂对象映射配置ResultMap的association association:映射到POJO的某个复杂类型属性,比如订单order对象里面包含user对象 表结构 项目结构 pom ...
- 操作系统|C语言模拟实现首次适应和最佳适应两种内存分配算法以及内存回收
两种算法 首次适应 首次适应算法从空闲分区表的第一个表目起查找该表,把最先能够满足要求的空闲区分配给作业,这种方法目的在于减少查找时间.为适应这种算法,空闲分区表(空闲区链)中的空闲分区要按地址由低到 ...