You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I've just pushed should be compliant and I think is good enough for an initial release. There's probably bugs and there are certainly performance problems, but I think it can go out.
@alkemist I’m trying to extract the sample code you linked to (since I cannot figure out how to run the tests you point to). The problem I am facing is that I cannot figure out how to publish ratpack 0.9.10-SNAPSHOT locally, what is the magic incantation? I tried adding the maven-publish plugin but that does not do anything when I say ./gradlew publishToMavenLocal (and ratpack-rx:publishToMavenLocal does not exist).
@alkemist Is there an example you'd like me to show in my presentation at QCon? Are you close to publishing to Maven Central a ratpack-rx version that supports RxJava 1.0? I tried with 0.9.9 but that isn't working (only 17 more days until 1.0 Final and no more breaking changes!).
@benjchristensen 0.9.10 was released today. It's in Jcenter but a successful sync to Central is proving elusive. Regarding what to demo, I just pushed examples for SSE and WebSocket streaming using publishers. Chunks, SSE and WebSocket are really the only useful ways we leverage RS streams ATM.
@benjchristensen The Akka part of the sample is fine, you can make it arbitrarily complex with all the operators out there.
The problem you are seeing very likely is that Akka streams buffer less elements, exposing the deadlock in your sample code: following a groupBy with a flatMap can only work under very specific circumstances, in general it is not a safe combination under bounded memory processing (since the even numbers will need to be buffered for as long as it takes to finish all the odd ones).
Concerning the exception itself: looking at the lines referenced in the stack trace it seems that data are just pushed too eagerly within the part leading up to observeOn, either by not respecting the signaled demand or by observeOn signaling more than it can take in. Do the RxJava or Reactor versions also work if you insert a Thread.sleep(1) within the map operation?
very likely is that Akka streams buffer less elements
How much it buffers shouldn't matter, as request(n) will determine how much it requests. One impl should be able to request(1) and another request(Long.MAX_VALUE) and it work.
exposing the deadlock in your sample code: following a groupBy with a flatMap can only work under very specific circumstances
What do you mean by this? The groupBy and flatMap uses cases work and correctly slow down (i.e. apply backpressure) to whatever the slowest group is. It would only "dead lock" as you call it if you completely blocked one group, which is exactly what should happen in a backpressure case. The user is free to decouple fast and slow streams if they wish by using a multitude of different operators that will make it behave differently (such as sample, throttle, onBackpressureBuffer, onBackpressureDrop, debounce, buffer, window, etc).
it seems that data are just pushed too eagerly within the part leading up to observeOn
That's correct, hence the problem. It works with Rx+Reactor and with Rx by itself, which implies that the request(n) is not correctly being composed through when it is Rx+Akka. It may be the RxJavaReactiveStream implementation, but Rx+Reactor are working with the exact same use case.
I have not yet spent the time to debug where too much is being requested or the request is being lost.
I'll paste examples below using Thread.sleep to demonstrate that it works with RxJava by itself or with RxJava+Reactor.
Here is one that multicasts a stream (use publish) creates 2 async/parallel streams off of it (odd and even using filtering) then zips them together with one of the streams slow.
packagereactive_streams_interop;
importjava.util.concurrent.atomic.AtomicInteger;
importrx.Observable;
importrx.schedulers.Schedulers;
publicclassRxJavaPublishZip {
publicstaticvoidmain(String... args) {
finalAtomicIntegernumEmitted = newAtomicInteger();
Observable<Object> strings = Observable.range(1, 1000000).doOnNext(i -> numEmitted.incrementAndGet())
.publish(oi -> {
// schedule it so we are async and need backpressureObservable<String> odd = oi.observeOn(Schedulers.computation())
.filter(i -> i % 2 != 0).map(i -> i + "-odd").map(s -> {
// make odd slowtry {
Thread.sleep(1);
} catch (Exceptione1) {
}
returns;
});
Observable<String> even = oi.observeOn(Schedulers.computation())
.filter(i -> i % 2 == 0).map(i -> i + "-even");
returnObservable.zip(odd, even, (o, e) -> o + " " + e + " Thread: " + Thread.currentThread());
}).take(2000);
strings.toBlocking().forEach(System.out::println);
System.out.println("Number emitted from source (should be ~4000): " + numEmitted.get());
}
}
You can see the backpressure happening because the num emitted is < 5000 in this case rather than spinning and emitting all 1000000. It is not exactly 4000 because we are async and allow buffers in observeOn to fill.
If I put take on the individual streams that it would be exact as it would propagate through, but via zip it can't do that as it splits streams, so each stream maintains its own backpressure and zip also maintains its own.
@benjchristensen do you have in mind anything more than what we have now in terms of the general pattern? Where the proposed pattern is to have more projects in examples/ integrating different libraries/frameworks.
I'd like to encourage the respective library/framework owners to contribute examples. I don't intend to do it.
Activity
benjchristensen commentedon Oct 1, 2014
/cc @smaldini
rkuhn commentedon Oct 29, 2014
I’m currently looking into trying out some interop with Akka Streams, are artifacts published somewhere?
ldaley commentedon Oct 29, 2014
You’ll have to hold off. It’s not spec compliant yet. Once it is I’ll get some artefacts published.
rkuhn commentedon Oct 29, 2014
Bummer; I guess I’ll look into ratpack and Reactor then (want to show something at conferences next week).
ldaley commentedon Oct 29, 2014
I’m actively working on this right now. Should have it working in the next day or two.
rkuhn commentedon Oct 29, 2014
Cool, would you please ping this issue when I should try it out? Thanks!
ldaley commentedon Oct 29, 2014
What I've just pushed should be compliant and I think is good enough for an initial release. There's probably bugs and there are certainly performance problems, but I think it can go out.
@benjchristensen how do we get a binary out?
benjchristensen commentedon Oct 29, 2014
I'll push the buttons (since we haven't yet got the fully self-serve Travis based release process working yet like RxScala).
benjchristensen commentedon Oct 29, 2014
0.2.0 is released on BinTray (https://bintray.com/reactivex/RxJava/RxJavaReactiveStreams/0.2.0/view) and is making its way to Maven Central.
@alkemist Thank you for your work on this. Would you mind providing a section on the README or in the Wiki with basic usage examples?
smaldini commentedon Oct 29, 2014
Looking forward to it for my next demos :D
On Wed, Oct 29, 2014 at 5:23 PM, Ben Christensen notifications@github.com
wrote:
Stéphane
benjchristensen commentedon Oct 29, 2014
It can be seen on Maven Central now: http://repo1.maven.org/maven2/io/reactivex/rxjava-reactive-streams/0.2.0/
rkuhn commentedon Oct 29, 2014
Thanks a lot, @benjchristensen and @alkemist!
ldaley commentedon Oct 30, 2014
Pushed one example of interop with Ratpack: https://github.com/ReactiveX/RxJavaReactiveStreams/blob/0.x/examples/ratpack/src/test/java/rx/reactivestreams/example/ratpack/RatpackExamples.java#L46-46
Leaving this ticket open for more examples and some stuff in the README.
benjchristensen commentedon Oct 30, 2014
Cool, nice to see that code, that's very helpful.
rkuhn commentedon Oct 30, 2014
@alkemist I’m trying to extract the sample code you linked to (since I cannot figure out how to run the tests you point to). The problem I am facing is that I cannot figure out how to publish ratpack 0.9.10-SNAPSHOT locally, what is the magic incantation? I tried adding the maven-publish plugin but that does not do anything when I say
./gradlew publishToMavenLocal(and ratpack-rx:publishToMavenLocal does not exist).17 remaining items
benjchristensen commentedon Nov 2, 2014
@rkuhn Are you okay with me using the following slide? Is there anything you'd like me to change?
If you can provide me a more realistic example I'd happily change. For example an Akka Actor that acts as a source to RxJava for consumption.
benjchristensen commentedon Nov 2, 2014
@smaldini I can't find a logo for Reactor, is there something I should use?
benjchristensen commentedon Nov 2, 2014
@alkemist Is there an example you'd like me to show in my presentation at QCon? Are you close to publishing to Maven Central a ratpack-rx version that supports RxJava 1.0? I tried with 0.9.9 but that isn't working (only 17 more days until 1.0 Final and no more breaking changes!).
ldaley commentedon Nov 2, 2014
@benjchristensen 0.9.10 was released today. It's in Jcenter but a successful sync to Central is proving elusive. Regarding what to demo, I just pushed examples for SSE and WebSocket streaming using publishers. Chunks, SSE and WebSocket are really the only useful ways we leverage RS streams ATM.
Up to you what you want to show.
rkuhn commentedon Nov 3, 2014
@benjchristensen The Akka part of the sample is fine, you can make it arbitrarily complex with all the operators out there.
The problem you are seeing very likely is that Akka streams buffer less elements, exposing the deadlock in your sample code: following a groupBy with a flatMap can only work under very specific circumstances, in general it is not a safe combination under bounded memory processing (since the even numbers will need to be buffered for as long as it takes to finish all the odd ones).
Concerning the exception itself: looking at the lines referenced in the stack trace it seems that data are just pushed too eagerly within the part leading up to
observeOn, either by not respecting the signaled demand or byobserveOnsignaling more than it can take in. Do the RxJava or Reactor versions also work if you insert aThread.sleep(1)within themapoperation?benjchristensen commentedon Nov 3, 2014
@alkemist Thanks, I'll try that.
benjchristensen commentedon Nov 3, 2014
@rkuhn
How much it buffers shouldn't matter, as
request(n)will determine how much it requests. One impl should be able torequest(1)and anotherrequest(Long.MAX_VALUE)and it work.What do you mean by this? The
groupByandflatMapuses cases work and correctly slow down (i.e. apply backpressure) to whatever the slowest group is. It would only "dead lock" as you call it if you completely blocked one group, which is exactly what should happen in a backpressure case. The user is free to decouple fast and slow streams if they wish by using a multitude of different operators that will make it behave differently (such assample,throttle,onBackpressureBuffer,onBackpressureDrop,debounce,buffer,window, etc).That's correct, hence the problem. It works with Rx+Reactor and with Rx by itself, which implies that the
request(n)is not correctly being composed through when it is Rx+Akka. It may be the RxJavaReactiveStream implementation, but Rx+Reactor are working with the exact same use case.I have not yet spent the time to debug where too much is being requested or the request is being lost.
I'll paste examples below using
Thread.sleepto demonstrate that it works with RxJava by itself or with RxJava+Reactor.benjchristensen commentedon Nov 3, 2014
Example of RxJava + Reactor where the
evengroup takes 10ms per item and theoddgroup takes 1ms per itemYou end up with output such as this:
benjchristensen commentedon Nov 3, 2014
RxJava by itself doing
groupBy+flatMap:benjchristensen commentedon Nov 3, 2014
Here is one that multicasts a stream (use
publish) creates 2 async/parallel streams off of it (odd and even using filtering) then zips them together with one of the streams slow.Output would be like this:
You can see the backpressure happening because the num emitted is < 5000 in this case rather than spinning and emitting all 1000000. It is not exactly 4000 because we are async and allow buffers in
observeOnto fill.If I put
takeon the individual streams that it would be exact as it would propagate through, but viazipit can't do that as it splits streams, so each stream maintains its own backpressure and zip also maintains its own.ldaley commentedon Nov 8, 2014
@benjchristensen do you have in mind anything more than what we have now in terms of the general pattern? Where the proposed pattern is to have more projects in
examples/integrating different libraries/frameworks.I'd like to encourage the respective library/framework owners to contribute examples. I don't intend to do it.
ldaley commentedon Nov 8, 2014
Looking at the readme again, we probably do want at least one example of real interop there.
benjchristensen commentedon Nov 8, 2014
@alkemist The examples above are sufficient enough, but we should get them into
/examplesor something like that as you suggest, and probably have the simple ones presented in the README or wiki similar to how my slides give a quick intro: https://speakerdeck.com/benjchristensen/reactive-programming-with-rx-at-qconsf-2014?slide=158benjchristensen commentedon Nov 11, 2014
@rkuhn Any thoughts on the examples above? I'm interested in your perspective since you stated that
groupByandflatMapare not safe.rkuhn commentedon Nov 11, 2014
Sorry for the delay, I’m traveling too much this month; I’ll try to elaborate later this week, otherwise we can talk it through next week at React.