Simplify HttpComponents5MessageSender

Previously, HttpComponents5MessageSender can be configured to use both
a custom HttpClient or configure one using a number of convenient
properties. This setup creates an odd arrangement where calling those
convenient methods once an HttpClient is set throws an exception as
the implementation supports one or the other.

This commit moves the first use case in a simple implementation that
only accepts a custom HttpClient or the state of
HttpComponents5ClientFactory for convenience and discoverability.

Specifying an HttpComponents5MessageSender is deprecated as a result.

Closes gh-1519
This commit is contained in:
Stéphane Nicoll
2025-04-08 12:59:03 +02:00
parent cf9295b887
commit f250abb0cf
7 changed files with 286 additions and 103 deletions

View File

@@ -38,7 +38,7 @@ You can set one or more message senders by using the `messageSender` or `message
There are three implementations of the `WebServiceMessageSender` interface for sending messages over HTTP.
The default implementation is the `HttpUrlConnectionMessageSender`, which uses the facilities provided by Java itself.
The alternatives are either `JdkHttpClientMessageSender` that uses the JDK's `HttpClient`, or `HttpComponents5MessageSender`, which uses the https://hc.apache.org/httpcomponents-client-ga[Apache HttpClient].
The alternatives are either `JdkHttpClientMessageSender` that uses the JDK's `HttpClient`, or `HttpComponents5MessageSender`/`SimpleHttpComponents5MessageSender`, which use the https://hc.apache.org/httpcomponents-client-ga[Apache HttpClient].
Use the latter if you need more advanced and easy-to-use functionality (such as authentication, HTTP connection pooling, and so forth).
To use the HTTP transport, either set the `defaultUri` to something like `http://example.com/services` or supply the `uri` parameter for one of the methods.