Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhaval201279/c557ce9ccc16110fe3a4fdfbba918ff3 to your computer and use it in GitHub Desktop.
Save dhaval201279/c557ce9ccc16110fe3a4fdfbba918ff3 to your computer and use it in GitHub Desktop.
Http client config with house keeping of idle and expired connections
public Runnable idleAndExpiredConnectionProcessor(final PoolingHttpClientConnectionManager connectionManager) {
return new Runnable() {
@Override
@Scheduled(fixedDelay = 20000)
public void run() {
try {
if (connectionManager != null) {
connectionManager.closeExpiredConnections();
connectionManager.closeIdleConnections(IDLE_CONNECTION_WAIT_TIME_SECS, TimeUnit.SECONDS);
}
} catch (Exception e) {
// Log errors
}
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment