Skip to content

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

License

Notifications You must be signed in to change notification settings

nhenneaux/resilient-httpclient

Repository files navigation

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

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Languages