Checkpoint operator

The Debug hook discussed in the previous section has a global impact, instrumenting all Flux/Mono instances. Consequently, the impact of the debug hook is application-wide. Alternatively, Reactor also provides a checkpoint operator, which can only alter a particular Flux stream. The checkpoint operator instruments a Reactor Streams after the operator invocation. We can alter our previous test case as follows:

@Testpublic void testPublisherStub() throws Exception {  Flux<Long> fibonacciGenerator =     getFibonacciGenerator().checkpoint();    StringWriter out = new StringWriter();  new PrintService().printEventNumbers(fibonacciGenerator,   new PrintWriter(out));  assertTrue(out.getBuffer().length() >0);}

In the preceding code, ...

Get Hands-On Reactive Programming with Reactor now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.