OnSubscribeRange with AsyncOnSubscribe does not work without backpressure
See original GitHub issueHi, im trying to implement observable with backpressure. i’ve investigated a bit and came with this solution:
@Test
public void testObservable() throws Exception {
Observable<Integer> observable = Observable.create(new AsyncOnSubscribe<Void, Integer>() {
@Override
protected Void generateState() {
return null;
}
@Override
protected Void next(Void state,
long requested,
Observer<Observable<? extends Integer>> observer) {
observer.onNext(Observable.create(
new OnSubscribeRange(0, Integer.MAX_VALUE -1)));
return null;
}
});
observable
// .observeOn(Schedulers.computation())
// .subscribeOn(Schedulers.io())
.subscribe(d -> System.out.println(">>>>>>"));
sleep(10000);
}
I’ve found out that AsyncOnSubscribe provides basics for back pressure support and im using the OnSubscribeRange to n times call some method(via chained map operator)
The problem is that it seems its very unreliable in initialization. It works if i do the backpressure in subscriber(request(n)) but once i try to go without backpressure it does not work. Data is emitted but does not reach the subscriber. I believe its being accumulated in rx.observables.AsyncOnSubscribe.AsyncOuterManager#subscribeBufferToObservable endlessly. As if the subscribe was not noticed.
Am i doing something wrong? I understand that the AsyncOnSubscribe is experimental, so if there is any recommended way how to implement backpressure support correctly please point me to the right direction.
Currently we are using rxjava 1.1.2 NOTE: I understand that the OnSubscribeRange supports only max int values so i implemented OnSubscribeLongRange but the same behaviour applies for both.
Thank you in advance, Viliam
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
A more concise way to write this would be to use the static initializer on SynOnSubscribe.createStateless(…)
On Wed, Mar 30, 2016, 07:03 Witko notifications@github.com wrote:
Thanks! even nicer