Incompatibility with ReactiveStreams / Upgrade to RxJava2 [DATACOUCH-343]
Nilesh Mevada opened DATACOUCH-343 and commented
Hi,
I am using reactive workflow of spring-data-couchbase:3.0.0.RC2 (automatically pulled by Spring Boot 2.0.0.M3).
RxJava2 allows transition from/to ReactiveStreams types. I use Reactor for my reactive workflows. However, while using following code gives me compilation error.
//repository is of type - ReactiveCouchbaseSortingRepository<>
Observable<User> observable = repository.getCouchbaseOperations().findByN1QL(query, User.class); // #1
return Flux.from(observable.toFlowable(BackpressureStrategy.BUFFER)); // #2
Now, #1 returns rx.Observable which is from RxJava1. This does not allow me to use #2 (which tries to convert RxJava2's Observable to Reactor's Flow class).
Even though I force my project build to use RxJava2; it won't work, because, as of spring-data-couchbase:3.0.0.RC2, the code still uses RxJava1.
So, is it possible to change the dependent library from RxJava1 to RxJava2? That would really be helpful. And, when can we possibly expect it to be available?
Notes :
- I have marked 3.0 GA version whereas my code is against 3.0.0.RC2 version (as that is what spring boot automatically pulls in.)
PS : Hope I have given enough details. Let me know if I haven't.
Affects: 3.0 GA (Kay)
Mark Paluch commented
The Couchbase driver is based on RxJava1 and so does the reactive Template.
You have two options to obtain a Publisher (Flux/Mono):
- Declare a query method on your repository returning a reactive streams return type. Spring Data takes care of reactive type adoption for you.
- If you can't use a repository method, then use rxjava-reactive-streams as adapter library to adapt
ObservabletoPublisher:
Observable<User> observable = getCouchbaseOperations().findByN1QL(query, User.class);
Flux.from(RxReactiveStreams.toPublisher(observable));
Nilesh Mevada commented
Works like a charm! Thanks a lot Mark.
Note for me: I should do some better googling before I put a task in here. :)
Mark Paluch commented
Requesting an upgrade to Reactive Streams/RxJava 2 is a valid point though. RxJava 1 is no longer in active development and EOL is announced for March 2018. Let's keep that ticket open to await some advice from the Couchbase team in regard to the direction towards the driver will head to
subhashni balakrishnan commented
We have it on the roadmap, most likely the 3.0 version of the SDK would have support for RxJava2.
David Nault commented
Version 3 of the Couchbase Java SDK will be built on Reactor instead of RxJava