在运行时修改Hikari属性 [英] Modify Hikari properties at runtime

查看:438
本文介绍了在运行时修改Hikari属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在哪里可以找到有关可以在运行时修改的Hikari属性的信息? 我试图修改 connectionTimeout .我可以做到,并且将在HikariDataSource中对其进行修改,没有例外(通过设置然后获取属性进行检查),但是它没有任何效果. 如果我最初是这样做的:

Where can I find information about Hikari properties that can be modified at runtime? I tried to modify connectionTimeout. I can do it and it will be modified in the HikariDataSource without an exception (checked by setting and then getting the property) but it takes no effect. If I initially do:

HikariConfig config = new HikariConfig();
config.setConnectionTimeout(12000);
HikariDataSource pool = new HikariDataSource(config);

以后我会做

config.setConnectionTimeout(5000);

Hikari尝试从12秒(而不是5秒)建立新连接.

Hikari tries to get a new connection for 12 seconds instead of 5 seconds.

还是有一种方法可以有效地更改值? 还有其他具有相同行为的属性吗?

Or is there a way to change the value with effect? Are there other properties with the same behaviour?

推荐答案

您无法通过在config对象上重置属性值来动态更新属性值-实例化Hikari池时,该config对象最终会被读取一次(请看一下在 PoolBase.java 看看它是如何工作的.

You can't dynamically update the property values by resetting them on the config object - the config object is ultimately read once when instantiating the Hikari Pool (have a look at the source code in PoolBase.java to see how this works.

但是,您可以执行所需的操作,并在运行时通过JMX更新连接超时值. hikari文档此处

You can however do what you want and update the connection timeout value at runtime via JMX. How to do this is explained in the hikari documentation here

这篇关于在运行时修改Hikari属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆