Skip to content

Inject Pooling Connection Manager - #2025

Open
danielrohe wants to merge 2 commits into
Adyen:mainfrom
danielrohe:pooling-connection-manager
Open

Inject Pooling Connection Manager#2025
danielrohe wants to merge 2 commits into
Adyen:mainfrom
danielrohe:pooling-connection-manager

Conversation

@danielrohe

Copy link
Copy Markdown

In a microservices especially based on Spring Boot it is often useful to inject a shared PoolingHttpClientConnectionManager into all clients including the AdyenHttpClient. The benefits are

  • users of the Adyen Java Library can configure the pool size correctly based on their needs on the shared pooling connection manager before injecting it into the AdyenHttpClient and do not need to rely on the quite low default configuration (max 25 connections to different Adyen API domains and max 5 connections to the same Adyen API domain). The default with max 5 connections at the same time to one Adyen API domain can cause latency issues because of pool exhaustion under high load
  • especially within Spring Boot applications users of the Adyen Java Library can inject a pooling connection manager that is connected to telemetry systems like micrometer making it possible to observe the load on the connection pool used by the AdyenHttpClient.

Created the no-args constructor for backward compatibility and added one for injecting a shared PoolingHttpClientConnectionManager. Adjusted the createHttpClientWithSocketFactory method to consider the shared connetction pool manager if necessary.

@danielrohe
danielrohe requested a review from a team as a code owner August 7, 2026 13:13
@danielrohe danielrohe changed the title Possibility to inject Pooling Cconnection Manager Inject Pooling Connection Manager Aug 7, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for a shared PoolingHttpClientConnectionManager in AdyenHttpClient by adding a new constructor and updating the HTTP client builder to use the shared manager when provided. The review feedback recommends declaring the sharedConnectionManager field as final to guarantee thread safety and safe publication. Additionally, it suggests adding Javadoc documentation to clarify that custom SSL configurations and connection-level timeouts from the Config class are ignored or must be pre-configured when using a shared connection manager.

Comment thread src/main/java/com/adyen/httpclient/AdyenHttpClient.java Outdated
@gcatanese

Copy link
Copy Markdown
Contributor

Thanks for the contribution @danielrohe . Injecting a connection manager is valuable for advanced use cases such as Micrometer telemetry, pool sharing, and lower-level Apache configuration.

Before merging, could you please:

  • Fix the trailing whitespace reported by Checkstyle
  • Add tests proving that the injected manager is used, can be shared across clients, and remains open when an AdyenHttpClient is closed.
  • Verify that custom pool limits remain unchanged and that the no-argument constructor retains its existing ownership and lifecycle behavior.

In a new issue we will expose in the Config object the pool-capacity configuration (maxTotalConnections and maxConnectionsPerRoute), I think those settings are also important in the default implementation offered by the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants