cancel
Showing results for 
Search instead for 
Did you mean: 

Join the community at Nodes 2022, our free virtual event on November 16 - 17.

Reactive driver use

eric13013
Node Clone

Hi,

I would like to use the Neo4j Reactive driver with RxJava2 in a standard java program.

First question : is it relevant to use it in this case or should I use the "blocking style" session instead ?

If relevant, I see in the javadoc of RxSession#readTransaction this :

Returned publisher and given {@link RxTransactionWork} is completed/executed by an IO thread which should never block. Otherwise IO operations on this and potentially other network connections might deadlock. Please do not chain blocking operations like {@link CompletableFuture#get()} on the returned publisher and do not use them inside the RxTransactionWork.

So I would like to know if the use of blockingGet is allowed :

MyPOJO myPOJO = Flowable.using(
                    driver::rxSession,
                    session -> session.readTransaction(tx -> tx.run("myQuery").records()),
                    session -> Observable.fromPublisher(session.close()).subscribe()
            )
            .map(FROM_RECORD_TO_POJO)
           .collect(() -> new MyPOJOBuilder(), MyPOJOBuilder::add)
           .map(myPOJOBuilder::build)
           .blockingGet();

If blockingGet cannot be used, how can I get back my POJO in a standard java program on the main thread ?

Thanks

0 REPLIES 0