The following test method:
@Test
void testMe() {
Flux.just(1, 2, 3, 4, 5)
.map(this::saveInDb)
.toStream().count();
}
int saveInDb(int element) {
System.out.println(element + " successfully stored in DB.");
return element;
}
prints always:
1 successfully stored in DB.
2 successfully stored in DB.
3 successfully stored in DB.
4 successfully stored in DB.
5 successfully stored in DB.
The question that I have: how to prevent any saving to DB when some particular element available in the Flux?
For example: I do not want to store anything to DB when element 5
exists in Flux.
Is it even possible to implement this requirement in a non-blocking fashion?