Skip to content

Expose PoolingHttpClientConnectionManager statistics via JMX

License

Notifications You must be signed in to change notification settings

testingsyndicate/hc-jmx

Repository files navigation

HC-JMX

Maven Central GitHub license

JMX MXBean for Apache HttpComponents HttpClient 4.5.x

Summary

View HttpClient metrics from a PoolingHttpClientConnectionManager

  • MaxTotal*
  • DefaultMaxPerRoute*
  • Leased
  • Pending
  • Available
  • RoutesTotal

Metrics marked with an asterisk are read/write

Available to view via JMX compatible monitoring and profiling tools such as AppDynamics, DataDog and VisualVM

Usage

<dependency>
    <groupId>com.testingsyndicate</groupId>
    <artifactId>hc-jmx</artifactId>
    <version>...</version>
</dependency>
<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5</version>
</dependency>
// Create a PoolingHttpClientConnectionManager
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();

// Register it with the name "default"
HcJmx.getInstance().register(connectionManager);
// Or pass a Client directly (extracts PoolingHttpClientConnectionManager using reflection)
HttpClient client = HttpClients.custom()
    .setMaxConnPerRoute(10)
    .setMaxConnTotal(15)
    .build();

HcJmx.getInstance().register(client);

Screenshots

Metrics shown in VisualVM

VisualVM Apache HttpClient PoolingHttpClientConnectionManager

License

MIT

About

Expose PoolingHttpClientConnectionManager statistics via JMX

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages