[resteasy-dev] Asynchronous invocation interceptor for client

Alessio Soldano asoldano at redhat.com
Wed Nov 21 04:45:31 EST 2018


Hi Michał,
I've reviewed your code and it looks good to me, the integration with
RESTEasy is fine.
Thanks

On Wed, Nov 21, 2018 at 9:24 AM Michal Szynkiewicz <mszynkie at redhat.com>
wrote:

> We need to somehow share the interceptor between the thread that calls the
> client and the thread that performs the request.
>
> The glue code is in `AsyncInvocationHandler` [1]. It stores the
> interceptors in a `ThreadLocal`.
> When building the RESTEasy client, we wrap the `ExecutorService` with a
> wrapper that decorates every `Runnable` and `Callable` with invocation of
> the interceptor.
> The code is again in the handler [1]. It takes the value from the
> `ThreadLocal` and creates a "wrapped" `Runnable`/`Callable`.
>
> The `ThreadLocal` is filled from a proxy that we wrap calls to the
> RESTEasy client in [2].
>
> The whole change:
> https://github.com/mkouba/smallrye-rest-client-1/commit/cff4eb8ea1337fcb127aa29a248bbfcf6d5edbf4
>
> Please let me know if what I wrote is unclear.
>
> Regards,
> Michał
>
> [1]
> https://github.com/mkouba/smallrye-rest-client-1/blob/cff4eb8ea1337fcb127aa29a248bbfcf6d5edbf4/implementation/src/main/java/io/smallrye/restclient/async/AsyncInvocationInterceptorHandler.java
> [2]
> https://github.com/mkouba/smallrye-rest-client-1/commit/cff4eb8ea1337fcb127aa29a248bbfcf6d5edbf4#diff-7cffec08a6622027ad1d3f3f47eea396R100
>
>
> On Tue, Nov 20, 2018 at 4:29 PM Alessio Soldano <asoldano at redhat.com>
> wrote:
>
>> I've been looking a bit at this, but haven't seen anything really meant
>> for this. Can you share a link to what you're doing with the
>> ExecutorService btw? Maybe that can inspire someone...
>> Cheers
>>
>> On Tue, Nov 20, 2018 at 12:38 PM Michal Szynkiewicz <mszynkie at redhat.com>
>> wrote:
>>
>>> Hi,
>>>
>>> We are working on MicroProfile Rest Client 1.1 for SmallRye.
>>> One of the requirements is to implement AsyncInvocationInterceptor, an
>>> interceptor for asynchronous client invocation.
>>> The interceptor has two methods (more details in [1]):
>>>
>>>    - prepareContext, executed in the thread that calls the client
>>>    - applyContext, executed in the thread that makes the request.
>>>
>>> Moreover, there is a single instance of the interceptor per request (not
>>> per client).
>>>
>>> Does RestEasy have some feature that we could use to implement executing
>>> the applyContext method? We couldn't find anything that would work for us
>>> in the JAX-RS itself.
>>>
>>> We implemented a wrapper for ExecutorService that decorates runnables
>>> with code that calls the interceptor but we're hoping there may be a better
>>> solution.
>>>
>>> Thanks,
>>> Michał
>>>
>>>
>>>
>>> [1]
>>> https://github.com/eclipse/microprofile-rest-client/blob/1.1.X-service/spec/src/main/asciidoc/async.asciidoc
>>> _______________________________________________
>>> resteasy-dev mailing list
>>> resteasy-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/resteasy-dev
>>>
>>
>>
>> --
>>
>> Alessio Soldano
>>
>> Associate Manager
>>
>> Red Hat
>>
>> <https://www.redhat.com>
>> <https://red.ht/sig>
>>
>

-- 

Alessio Soldano

Associate Manager, Software Engineering

Red Hat

<https://www.redhat.com>
<https://red.ht/sig>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/resteasy-dev/attachments/20181121/44f37e52/attachment-0001.html 


More information about the resteasy-dev mailing list