https://github.com/nhenneaux/resilient-httpclient
Java HTTP client with pooling and auto refresh of underlying IP addresses
https://github.com/nhenneaux/resilient-httpclient
dns http http2 httpclient java java-httpclient
Last synced: 16 days ago
JSON representation
Java HTTP client with pooling and auto refresh of underlying IP addresses
- Host: GitHub
- URL: https://github.com/nhenneaux/resilient-httpclient
- Owner: nhenneaux
- License: lgpl-3.0
- Created: 2019-11-04T15:34:11.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-11-25T17:06:38.000Z (2 months ago)
- Last Synced: 2025-11-28T22:21:42.181Z (2 months ago)
- Topics: dns, http, http2, httpclient, java, java-httpclient
- Language: Java
- Homepage:
- Size: 505 KB
- Stars: 12
- Watchers: 1
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Resilient HTTP with `java.net.http.HttpClient`
Client using a pool of HTTP clients targeting each a single IP. Each of them is refreshed based on HTTP health check and DNS query. It has the following features.
* Client side load balancing between all the IP behind the hostname
* Monitoring of all the IP behind the hostname at HTTP level
* Monitoring of the DNS
* TCP failover
* HTTP/2 with seamless fallback to HTTP/1

A presentation detailing the features of the client and comparing it with other Java HTTP clients (HttpUrlConnection, Apache, Jetty) [Presentation](https://docs.google.com/presentation/d/1ixrKR79pX5jDGRO46mA03r20n3sQGhu2TRYoe_uKFYI/edit?usp=sharing).
# Usage
```java
HttpClientPool singletonByHost = HttpClientPool.newHttpClientPool(new ServerConfiguration("openjdk.java.net"));
java.net.http.HttpClient resilientClient = singletonByHost.resilientClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://openjdk.java.net/"))
.build();
resilientClient.sendAsync(request, HttpResponse.BodyHandlers.ofString())
.thenApply(HttpResponse::body)
.thenAccept(System.out::println)
.join();
```
[](https://github.com/nhenneaux/resilient-httpclient/actions?query=workflow%3A%22Java+CI%22)
[](https://maven-badges.herokuapp.com/maven-central/com.github.nhenneaux.resilienthttpclient/monitored-httpclient)
[](https://sonarcloud.io/dashboard?id=nhenneaux_resilient-httpclient)
[](https://sonarcloud.io/dashboard?id=nhenneaux_resilient-httpclient)