Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-6881 Implement JAX-RS 2.1
  3. CXF-6833

support RxJava Observable<T> in return values as a more composeable alternative to Future<T>

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.2.0
    • JAX-RS
    • None
    • Unknown

    Description

      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:
      http://joluet.github.io/blog/2014/07/07/rxjava-retrofit/

      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.

      @GET("/session.json")
      Observable<LoginResponse> login();
      
      @GET("/user.json")
      Observable<UserState> getUserState();
      

      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:

      Observable.combineLatest(api.fetchUserProfile(), api.getUserState(),
      (user, userStatus) -> new Pair<>(user, userStatus));
      

      and you're done! There's support for timeouts and other kinds of composition mechanisms too.

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            jstrachan James Strachan
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: