-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supplying custom HttpClientBuilder to ApacheConnector #4210
Comments
Relates to #4104. The problem is that Apache HttpClientBuilder does not provide getters, so it is not possible to know what was configured in the HttpClientBuilder and what is yet to be configured. There would be needed some other approach. |
Thanks, @jansupol, for your comments. I'm pretty much open to any approach that would allow me to get my own HttpClientBuilder into ApacheConnector. I understand that you wouldn't know what had been set and what hadn't on my HttpClientBuilder and that things could get out of sync and it seems to me that that's a risk that someone would take when supplying his or her own builder. That risk could be documented. They'd have to understand that ApacheConnector would be making calls on their builder in accordance with its properties. That's a risk I'm willing to take. In the meantime, I've had to clone ApacheConnector to create my own MyApacheConnector (and MyApacheConnectorProvider) that uses Amazon's HttpClientBuilder so that I can build an HttpClient client that coordinates with AWS X-Ray. I guess that this is an appropriate approach as well although I won't be able to automatically benefit from any enhancements to ApacheConnector. Also, please note that I am suggesting providing an HttpClientBuilder whereas #4089 was talking about providing an HttpClient. I do see your comments in #4104 that adding another property into ApacheClientProperties has its own scaling problems and I appreciate that but I think that's what properties are for. So do you advise that creating my own custom connector provider and connector is the best way to go? Thanks. |
How about this one:
Usually, one would use the pre-configured httpClientBuilder to further configure it and return. You, on the other hand, could return the instrumented one. Unfortunatelly, the configuration using the properties would not work for you, then. The ApacheHttpClientBuilderConfigurator would just be registered on the Client |
To get a broader Apache Community on board: |
This would definitely help me. It is unfortunate that there are no getter methods on HttpClientBuilder but I could set the ones I need that I would normally set via ApacheConnectorProvider. Thank you. |
@jansupol Have you given any more thought on being able to make this configurable by the caller in final HttpClientBuilder clientBuilder = CachingHttpClients.custom(); |
@jansupol Just pinging ya again. I see version 2.32 is out and that usually means me updating our fork for this one little change to use |
I am writing a java AWS lambda and using Jersey as my REST client. AWS X-Ray is automatically connected to the lambda and I would to use the AWS X-Ray instrumented version of HttpClientBuilder but the current implementation of ApacheConnector does not permit that. This issue is similar to #4089 but for Apache HttpComponents HttpClient.
I propose adding a new property to ApacheClientProperties such as CLIENT_BUILDER which could be set to an HttpClientBuilder implementation which must be a subclass of org.apache.http.impl.client.HttpClientBuilder.
Then, the code in ApacheConnector could be enhanced to replace the line reading
with something like
where
getHttpClientBuilder()
looks likeThe text was updated successfully, but these errors were encountered: