HikariCP MBean (JMX) Monitoring and Management

The JMX MBean for HikariCP exposes:

  • Idle Connection count
  • Active Connections (in use)
  • Total Connections
  • The number of threads waiting for a connection

👉 In order to use JMX, you must set the pool property registerMbeans=true.

Note these values are extremely ephemeral and reflect a snapshot in time when measured. As each statistic is time-sensitive and collected independently, it is possible for values to not "add up" over short periods of time. Do not base any programmatic decisions based on these values, they are for monitoring purposed only.

Additionally, the following actions are invocable against the MBean:

  • softEvictConnections()
  • suspendPool()1
  • resumePool()1

1 This methods are only available if the pool has been configured with allowPoolSuspension=true.

These values are visible in a JMX management console such as jconsole.


Programmatic access

The Pool MBean is registered with the name:

com.zaxxer.hikari:type=Pool (poolName)

where poolName is a name you can set on the HikariConfig using setPoolName("foo"), or the auto-generated name (e.g. HikariPool-1).

The Pool Config MBean is registered with the name:

com.zaxxer.hikari:type=PoolConfig (poolName)

where poolName is a name you can set on the HikariConfig using setPoolName("foo"), or the auto-generated name (e.g. HikariPool-1).


Programatic access goes something like this:

MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName poolName = new ObjectName("com.zaxxer.hikari:type=Pool (foo)");
HikariPoolMXBean poolProxy = JMX.newMXBeanProxy(mBeanServer, poolName, HikariPoolMXBean.class);

int idleConnections = poolProxy.getIdleConnections();

The accessible attributes are IdleConnections, ActiveConnections, TotalConnections, ThreadsAwaitingConnection. Similarly, the softEvictConnections() and suspendPool()/resumePool() methods can be invoked using the MBean proxy.

The following properties are also configurable in real-time on the HikariConfig MBean as the pool is running via a JMX management console or programmatically as above:

  • connectionTimeout
  • validationTimeout
  • idleTimeout
  • maxLifetime
  • minimumIdle
  • maximumPoolSize
  • leakDetectionThreshold
  • username
  • password

 

 

https://github.com/brettwooldridge/HikariCP/wiki/MBean-(JMX)-Monitoring-and-Management

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值