nhenneaux / resilient-httpclient

Java HTTP client with pooling and auto refresh of underlying IP addresses

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Schema

A presentation detailing the features of the client and comparing it with other Java HTTP clients (HttpUrlConnection, Apache, Jetty) Presentation.

Usage

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();

Build Status Maven Central Quality Gate Status Coverage

About

Java HTTP client with pooling and auto refresh of underlying IP addresses

License:GNU Lesser General Public License v3.0


Languages

Language:Java 100.0%