[
https://issues.apache.org/jira/browse/CXF-6833?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15264327#comment-15264327
]
Sergey Beryozkin commented on CXF-6833:
---------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/commit/2fb1ccf6 is a basic client
test using Observable.
Any tip on how to optimize
from
{code:java}
@Test
public void testGetHelloWorldAsyncObservable() throws Exception {
String address = "http://localhost:" + PORT + "/reactive/textAsync";
WebClient wc = WebClient.create(address);
Observable<String> obs =
getObservable(wc.accept("text/plain").async().get(String.class));
obs.subscribe(s -> assertResponse(s));
}
private void assertResponse(String s) {
assertEquals("Hello, world!", s);
}
{code}
to
@Test
public void testGetHelloWorldAsyncObservable() throws Exception {
String address = "http://localhost:" + PORT + "/reactive/textAsync";
WebClient wc = WebClient.create(address);
Observable<String> obs =
getObservable(wc.accept("text/plain").async().get(String.class));
// how to make it compile:
// assertEquals("Hello, world!", obs.subscribe(s -> );
}
> support RxJava Observable<T> in return values as a more composeable
> alternative to Future<T>
> --------------------------------------------------------------------------------------------
>
> 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<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.
> {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 too.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)