2
votes

I am trying to migrate a Reactive project from rxjava 1 to version 2. I was using an AsyncEmitter to attach to an existing feed, by specifiying a BackpressureMode. However I am not finding a comparable way to do this in rxjava2. What replaced AsyncEmitter in rxjava 2? I see there are a number of emitter implementations, but none accept a BackPressureStrategy.

I tried

FlowableCreate flowableCreate = 
         new FlowableCreate(source, BackpressureStrategy.LATEST);
flowableCreate.subscribe(System.out::println);

and it compiles fine, but execution fails right away with:

Error:(123, 23) java: cannot access org.reactivestreams.Subscriber class file for org.reactivestreams.Subscriber not found. Huh?

1
AFAIK, in RxJava 2 you have Flowable that supports backpressure and Observable which does not. Perhaps you want create an Observable first and then switch to a Flowable? - Tassos Bassoukos
Tried that, but weird compilation errors. - Vinny Gray
Looks like an IntelliJ bug. This works fine on the command line. - Vinny Gray

1 Answers

2
votes

In 2.x, the method you are looking for is Flowable.create().

You get the cannot access org.reactivestreams.Subscriber likely because you don't use 2.0.5+ with maven or forgot to download the org.reactivestreams:reactivestreams dependency of RxJava 2.