cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrei Ivanov (JIRA)" <>
Subject [jira] [Commented] (CXF-6833) support RxJava Observable<T> in return values as a more composeable alternative to Future<T>
Date Fri, 29 Apr 2016 10:43:12 GMT


Andrei Ivanov commented on CXF-6833:

On other standard web projects I used to create a separate module with the REST API (service
interfaces and model classes) which would be shared by the server and client modules.

Now I'm actually trying to use the RxJava / Retrofit combination on Android and tried to use
the same approach, but now it seems I have to use either the Retrofit {{Call}}, which I don't
really want since it's very specific to it, or use call adapters as the standard JDK {{CompletableFuture}}
or RxJava's {{Observable}}.

As I would like to try to use RxJava for other things (,
{{Observable}} seems to be a nice choice.
Now I have the problem with the server side.
Is there a quick way to make CXF work with this, even in a synchronous way? Maybe just handle
result conversion somehow?

> support RxJava Observable<T> in return values as a more composeable alternative
to Future<T>
> --------------------------------------------------------------------------------------------
>                 Key: CXF-6833
>                 URL:
>             Project: CXF
>          Issue Type: Sub-task
>          Components: JAX-RS
>            Reporter: james strachan
>             Fix For: 3.2.0
> when invoking multiple REST services concurrently in a microservice kinda world it can
be really helpful to use RxJava's Observable<T> so that you can easily compose concurrent
asynchronous requests together.
> e.g. see this blog:
> Its basically about using RxJava's Observable<T> as the result type; which is a
little like a Future<T> but can handle streams of values and is composable.
> It would be great to do this both on the client and server side; as a server may invoke
multiple asynchronous back ends and return a composition of results etc.
> e.g.
> {code}
> @GET("/session.json")
> Observable<LoginResponse> login();
> @GET("/user.json")
> Observable<UserState> getUserState();
> {code}
> you can then use the Observable<T> composition methods to join / flatMap  to compose
multiple requests across different microservice invocations together with timeouts etc e.g.
to compose the latest from 2 calls:
> {code}
> Observable.combineLatest(api.fetchUserProfile(), api.getUserState(),
> (user, userStatus) -> new Pair<>(user, userStatus));
> {code}
> and you're done! There's support for timeouts and other kinds of composition mechanisms

This message was sent by Atlassian JIRA

View raw message