如何配置 NiFi 的 DBCPConnectionPool 不保持空闲连接打开?

How can I configure NiFi's DBCPConnectionPool not to keep idle connections open?

开箱即用,NiFi(至少从 1.8.0 开始)似乎为每个启用的 DBCPConnectionPool 控制器服务保持打开一个数据库连接。我有多个 DBCPConnectionPool 控制器服务配置为使用不同的选项访问同一台服务器,因此这很快就会增加到我的数据库服务器的有限数量的连接。我有一个每晚运行的预定工作流程。连接不需要处于活动状态,除非在很短的 window 时间内处于活动状态。

查看 DBCPConnectionPool documentation, it appears that there are not controller service configuration options associated with Apache Commons-DBCP BasicDataSource 参数,例如 minIdlemaxIdle,我认为在我的特定用例中它们都应该设置为 0。或者,我想我可以将 maxConnLifetimeMillis 设置为甚至在分钟范围内的东西并满足我的用例(不需要立即释放连接 但在合理的时间段内) .

有没有办法在不修改 DBCPConnectionPool 代码的情况下传递这个选项? Commons-DBCP 是否会通过将这些选项设置为 NiFi DBCPConnectionPool 控制器服务配置上的动态属性来接受这些作为 JDBC 参数传递的选项?

从 1.8.0 开始的 NiFi keeps one connection per database open at all times 因为它使用不清理连接的 Commons-DBCP 2.5.0 的默认配置。 timeBetweenEvictionRunsMillis 的 Commons-DBCP 默认值是 -1,这导致空闲连接逐出永远不会 运行。

NiFi 1.8.0 不需要 expose the Commons-DBCP configuration options 调整这些时间。

NiFi 1.9.0expose these settings, added in this commit.