Skip to content

Latest commit

 

History

History
29 lines (25 loc) · 1.99 KB

README.md

File metadata and controls

29 lines (25 loc) · 1.99 KB

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