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
Copy file name to clipboardExpand all lines: java-manual/modules/ROOT/pages/reactive.adoc
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,12 +114,12 @@ public class App {
114
114
<1> link:https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#usingWhen(org.reactivestreams.Publisher,java.util.function.Function,java.util.function.Function)[`Flux.usingWhen(resourceSupplier, workerClosure, cleanupFunction)`] is used to create a new session, run queries using it, and finally close it.
115
115
It will ensure the resource is alive for the time it is needed for, and allows to specify the cleanup operation to undertake at the end.
116
116
Read more on this pattern in xref:session-creation[Always defer session creation].
117
-
<2> `.usingWhen()` takes a _resource supplier_ in the form of a `Publisher`, hence why session creation is wrapped in a link:https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#just-T-[`Mono.just()`] call, which spawns a `Mono` from any value.
117
+
<2> `.usingWhen()` takes a _resource supplier_ in the form of a `Publisher`, hence why session creation is wrapped in a link:https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#just(T)[`Mono.just()`] call, which spawns a `Mono` from any value.
118
118
<3> The session creation is similar to the async case, and xref:transactions.adoc#_session_configuration[the same configuration methods] apply.
119
119
The difference is that the first argument must be `ReactiveSession.class`, and the return value is a link:https://neo4j.com/docs/api/java-driver/current/org.neo4j.driver/org/neo4j/driver/reactivestreams/ReactiveSession.html[`ReactiveSession`] object.
120
-
<4> The method link:https://neo4j.com/docs/api/java-driver/current/org.neo4j.driver/org/neo4j/driver/reactive/ReactiveSession.html#executeRead(org.neo4j.driver.reactive.ReactiveTransactionCallback)[`ReactiveSession.executeRead()`] runs a read transaction and returns a `Publisher` with the callee's return, which link:https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#fromDirect-org.reactivestreams.Publisher-[`Mono.fromDirect()`] converts into a `Mono`.
121
-
<5> The method link:https://neo4j.com/docs/api/java-driver/current/org.neo4j.driver/org/neo4j/driver/reactivestreams/ReactiveQueryRunner.html#method-summary[`tx.run()`] returns a `Publisher<link:https://neo4j.com/docs/api/java-driver/current/org.neo4j.driver/org/neo4j/driver/reactivestreams/ReactiveResult.html[ReactiveResult]>`, which link:https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#fromDirect-org.reactivestreams.Publisher-[`Mono.fromDirect()`] converts into a `Mono`.
122
-
<6> Before the final result is returned, link:https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#flatMapMany-java.util.function.Function-[`Mono.flatMapMany()`] retrieves the records from the result and returns them as a new `Flux`.
120
+
<4> The method link:https://neo4j.com/docs/api/java-driver/current/org.neo4j.driver/org/neo4j/driver/reactive/ReactiveSession.html#executeRead(org.neo4j.driver.reactive.ReactiveTransactionCallback)[`ReactiveSession.executeRead()`] runs a read transaction and returns a `Publisher` with the callee's return, which link:https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#fromDirect(org.reactivestreams.Publisher)[`Mono.fromDirect()`] converts into a `Mono`.
121
+
<5> The method link:https://neo4j.com/docs/api/java-driver/current/org.neo4j.driver/org/neo4j/driver/reactivestreams/ReactiveQueryRunner.html#method-summary[`tx.run()`] returns a `Publisher<link:https://neo4j.com/docs/api/java-driver/current/org.neo4j.driver/org/neo4j/driver/reactivestreams/ReactiveResult.html[ReactiveResult]>`, which link:https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#fromDirect(org.reactivestreams.Publisher)[`Mono.fromDirect()`] converts into a `Mono`.
122
+
<6> Before the final result is returned, link:https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#flatMapMany(java.util.function.Function)[`Mono.flatMapMany()`] retrieves the records from the result and returns them as a new `Flux`.
123
123
<7> The final cleanup closes the session.
124
124
<8> To show the result of the reactive workflow, `.block()` waits for the flow to complete so that values can be printed.
125
125
In a real application you wouldn't block but rather forward the records publisher to your framework of choice, which would process them in a meaningful way.
0 commit comments