eclipse-ee4j / eclipse-ee4j/jersey
jersey-apache-connector: Add support for custom ServiceUnavailableRetryStrategy
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
I was previously using Jersey 1.x, where I could manually configure the Apache HttpClient. Part of this configuration was a custom ServiceUnavailableRetryStrategy, which is required by my code to handle rate limiting on a remote system, and handle authentication.
I have now upgraded to the latest Jersey version, but unfortunately the new jersey-apache-connector doesn't allow me to configure a custom ServiceUnavailableRetryStrategy. For now I have simply copied the relevant connector code in my project, and added a property for configuring the ServiceUnavailableRetryStrategy, similar to the recently added property for RetryHandler.
Can you please add support for this to jersey-apache-connector, such that I no longer need a customized version?
Simple approach would be:
* Add the following to ApacheClientProperties:
```java
public static final String SERVICE_UNAVAILABLE_RETRY_STRATEGY = "jersey.config.apache.client.serviceUnavailableRetryStrategy";
```
* Add the following to ApacheConnector:
```java
final Object serviceUnavailableRetryStrategy = config.getProperties().get(ApacheClientProperties.SERVICE_UNAVAILABLE_RETRY_STRATEGY);
if (serviceUnavailableRetryStrategy != null && (serviceUnavailableRetryStrategy instanceof ServiceUnavailableRetryStrategy)) {
clientBuilder.setServiceUnavailableRetryStrategy((ServiceUnavailableRetryStrategy) serviceUnavailableRetryStrategy);
}
```
As a more structural solution, it would be nice if callers can have direct access to HttpClientBuilder and other HttpClient-related functionality to allow for full customization of the connection, to avoid having to add properties for every possible HttpClientBuilder configuration.
Contributor guide
Assessment
This issue has not been assessed yet.