Testing and debugging Project Reactor

A versatile testing framework accompanies the Reactor library. The io.projectreactor:reactor-test library offers all of the necessary tools for testing reactive workflows implemented with Project Reactor. Chapter 9Testing the Reactive Application, covers testing techniques that are applicable to reactive programming in detail.

Even though reactive code is not so easy to debug, Project Reactor provides techniques to simplify the debugging process if it is required. As in any callback-based framework, stack traces in Project Reactor are not very informative. They do not give the exact location in our code where an exceptional situation had happened. The Reactor library comes with the debugging-oriented capabilities of assembly-time instrumentation. The details of the assembly-time phase of the stream life cycle are covered in the Project Reactor advanced section.  This feature can be activated with the following code:

Hooks.onOperatorDebug();

When enabled, this feature begins gathering stack traces for all streams that are going to be assembled, and later this information can extend the stack trace information with the assembly information and, consequently, help spot any problems faster. However, the procedure of creating stack traces is costly. So, it should only be activated in a controlled manner, as a last resort. For more information regarding this feature, please refer to Reactor's documentation.

Also, Project Reactor's Flux and Mono types provide a handy method called log. It logs all signals that are passing through the operator. Many available method's customizations give enough freedom to track the required data, even in a debug situation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.165.70