Slide 125
Slide 125 text
#Devoxx #ReactiveProgramming @mp911de and @rotnroll666
@Test
void explicit() {
Function> actualWork = session ->
Flux.usingWhen(session.beginTransaction(),
// Yes, this looks pretty much like the `txFunction` in the example before
tx -> tx.run(
"CREATE (a:Person {name: $name}) RETURN id(a) as id",
parameters("name", NAME)
).records(),
RxTransaction::commit, // Success case
(tx, e) -> tx.rollback(), // Error / exceptional case
RxTransaction::commit // Cancelation
).map(r -> r.get("id").asLong());
Flux personCreation =
Flux.using(driver::rxSession, actualWork, RxSession::close);
}
Explicit