Return-Path: X-Original-To: apmail-cxf-issues-archive@www.apache.org Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 12C4F1892E for ; Fri, 29 Apr 2016 11:01:13 +0000 (UTC) Received: (qmail 55278 invoked by uid 500); 29 Apr 2016 11:01:13 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 55249 invoked by uid 500); 29 Apr 2016 11:01:13 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 55234 invoked by uid 99); 29 Apr 2016 11:01:12 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Apr 2016 11:01:12 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id CC1B22C1F54 for ; Fri, 29 Apr 2016 11:01:12 +0000 (UTC) Date: Fri, 29 Apr 2016 11:01:12 +0000 (UTC) From: "Sergey Beryozkin (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CXF-6833) support RxJava Observable in return values as a more composeable alternative to Future MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CXF-6833?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15263899#comment-15263899 ] Sergey Beryozkin commented on CXF-6833: --------------------------------------- I suppose you can have a MessageBodyWriter supporting Observable, so if the method returns Observable then this writer will be selected, and its writeTo method it will get the data in needs or may be will stream from it and write to OutputStream. I'm going to do a bit of home-work on it to get a better understanding of the whole technology. > support RxJava Observable in return values as a more composeable alternative to Future > -------------------------------------------------------------------------------------------- > > Key: CXF-6833 > URL: https://issues.apache.org/jira/browse/CXF-6833 > 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 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 as the result type; which is a little like a Future 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 login(); > @GET("/user.json") > Observable getUserState(); > {code} > you can then use the Observable 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 too. -- This message was sent by Atlassian JIRA (v6.3.4#6332)