public static void main(final String[] args) throws Exception {

        final CloseableHttpAsyncClient client = HttpAsyncClients.custom()
                .setH2Config(H2Config.custom()
                        .setPushEnabled(true)
                        .build())
                .setConnectionManager(PoolingAsyncClientConnectionManagerBuilder.create()
                        .setDefaultTlsConfig(TlsConfig.custom()
                                .setVersionPolicy(HttpVersionPolicy.FORCE_HTTP_2)
                                .build())
                        .build())
                .build();

        client.start();

        final RequestRouter<Supplier<AsyncPushConsumer>> pushRequestRouter = RequestRouter.<Supplier<AsyncPushConsumer>>builder()
                // Route all requests to the local authority
                .resolveAuthority(RequestRouter.LOCAL_AUTHORITY_RESOLVER)
                // Use the same route for all requests
                .addRoute(RequestRouter.LOCAL_AUTHORITY, "*", () -> new AbstractBinPushConsumer() {

                    @Override
                    protected void start(
                            final HttpRequest promise,
                            final HttpResponse response,
                            final ContentType contentType) {
                        System.out.println(promise.getPath() + " (push)->" + new StatusLine(response));
                    }

                    @Override
                    protected int capacityIncrement() {
                        return Integer.MAX_VALUE;
                    }

                    @Override
                    protected void data(final ByteBuffer data, final boolean endOfStream) {
                    }

                    @Override
                    protected void completed() {
                    }

                    @Override
                    public void failed(final Exception cause) {
                        System.out.println("(push)->" + cause);
                    }

                    @Override
                    public void releaseResources() {
                    }

                })
                .build();

        final HttpHost target = new HttpHost("https", "nghttp2.org");

        final BasicHttpRequest request = BasicRequestBuilder.get()
                .setHttpHost(target)
                .setPath("/httpbin/")
                .build();

        System.out.println("Executing request " + request);
        final Future<Void> future = client.execute(
                new BasicRequestProducer(request, null),
                new AbstractCharResponseConsumer<Void>() {

                    @Override
                    protected void start(
                            final HttpResponse response,
                            final ContentType contentType) {
                        System.out.println(request + "->" + new StatusLine(response));
                    }

                    @Override
                    protected int capacityIncrement() {
                        return Integer.MAX_VALUE;
                    }

                    @Override
                    protected void data(final CharBuffer data, final boolean endOfStream) {
                    }

                    @Override
                    protected Void buildResult() {
                        return null;
                    }

                    @Override
                    public void failed(final Exception cause) {
                        System.out.println(request + "->" + cause);
                    }

                    @Override
                    public void releaseResources() {
                    }

                },
                HttpAsyncClients.pushRouter(pushRequestRouter),
                null,
                null);
        future.get();

        System.out.println("Shutting down");
        client.close(CloseMode.GRACEFUL);
    }
This example demonstrates handling of HTTP/2 message exchanges pushed by the server.
httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java