You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Paul Carter-Brown <pa...@jini.guru> on 2019/04/22 19:29:25 UTC

JAX-RS 2.1 Reactive Client - Async HTTPClient

Hi,

I'm using TomEE 8 with CXF and have not been able to get the rx() client
pattern with CompletionStage to utilise the Apache non-blocking HTTP
Client. With the old .async() pattern and Futures it does use the async
client

I've created a simple app outside of TomEE and have the same behavior. Here
is a basic example:

        Client client = ClientBuilder.newBuilder().build();
        WebTarget target = client.target("http://www.simplesite.com/");
        Invocation.Builder builder = target.request();
        // THIS CALL USES sun.net.www.protocol.http.HttpURLConnection

CompletableFuture.allOf(builder.rx().get(String.class).thenAccept(res ->
System.out.println(res.length())).toCompletableFuture()).join();

        client = ClientBuilder.newBuilder().build();
        target = client.target("http://www.simplesite.com/");
        builder = target.request();
        String res;
        try {
            // THIS CALL USES cxf-rt-transports-http-hc
            res = builder.async().get(String.class).get();
            System.out.println(res.length());
        } catch (Exception ex) {
        }

I use stack traces at runtime to see which version is being used.

Is it possible to use the non-blocking HTTP client with the reactive client?

I need this as I want to create a purely non-blocking server where the
JAX-RS server is non-blocking (I have this working) and then if the server
does client calls to subsequent external rest services then these are also
non-blocking. The combination would allow for a server that does rest
orchestration without a thread being used for every inflight request.

Thanks

Paul

Disclaimer: This message and/or attachment(s) may contain
privileged, confidential and/or personal information. If you are not the
intended recipient you may not disclose or distribute any of
the information contained within this message. In such case you must
destroy this message and inform the sender of the error. Jini Guru may not
accept liability for any errors, omissions, information and viruses
contained in the transmission of this message. Any opinions, conclusions
and other information contained within this message not related to Jini
Guru official business is deemed to be that of the individual only and is
not endorsed by Jini Guru.

Re: JAX-RS 2.1 Reactive Client - Async HTTPClient

Posted by Paul Carter-Brown <pa...@jini.guru>.
Forgot to mention:

Same happens for version 3.2.7 and 3.3.1

Paul


On Mon, Apr 22, 2019 at 9:29 PM Paul Carter-Brown
<pa...@jini.guru> wrote:

> Hi,
>
> I'm using TomEE 8 with CXF and have not been able to get the rx() client
> pattern with CompletionStage to utilise the Apache non-blocking HTTP
> Client. With the old .async() pattern and Futures it does use the async
> client
>
> I've created a simple app outside of TomEE and have the same behavior.
> Here is a basic example:
>
>         Client client = ClientBuilder.newBuilder().build();
>         WebTarget target = client.target("http://www.simplesite.com/");
>         Invocation.Builder builder = target.request();
>         // THIS CALL USES sun.net.www.protocol.http.HttpURLConnection
>
> CompletableFuture.allOf(builder.rx().get(String.class).thenAccept(res ->
> System.out.println(res.length())).toCompletableFuture()).join();
>
>         client = ClientBuilder.newBuilder().build();
>         target = client.target("http://www.simplesite.com/");
>         builder = target.request();
>         String res;
>         try {
>             // THIS CALL USES cxf-rt-transports-http-hc
>             res = builder.async().get(String.class).get();
>             System.out.println(res.length());
>         } catch (Exception ex) {
>         }
>
> I use stack traces at runtime to see which version is being used.
>
> Is it possible to use the non-blocking HTTP client with the reactive
> client?
>
> I need this as I want to create a purely non-blocking server where the
> JAX-RS server is non-blocking (I have this working) and then if the server
> does client calls to subsequent external rest services then these are also
> non-blocking. The combination would allow for a server that does rest
> orchestration without a thread being used for every inflight request.
>
> Thanks
>
> Paul
>
> Disclaimer: This message and/or attachment(s) may contain
> privileged, confidential and/or personal information. If you are not the
> intended recipient you may not disclose or distribute any of
> the information contained within this message. In such case you must
> destroy this message and inform the sender of the error. Jini Guru may not
> accept liability for any errors, omissions, information and viruses
> contained in the transmission of this message. Any opinions, conclusions
> and other information contained within this message not related to Jini
> Guru official business is deemed to be that of the individual only and is
> not endorsed by Jini Guru.
>
>