The publisher-subscriber communication generates events throughout the lifecycle of a Reactive Stream. Reactor provides corresponding lifecycle methods that can be used to hook custom logic to each of the said events, as shown in the following table:
Event
|
Method
|
Subscribe event | doOnSubscribe |
Request event, for N items from the subscriber | doOnRequest |
Value event, for all generated values | doOnNext |
Error event, for any error by the publisher | doOnError |
Completion event | doOnCompletion |
Cancel event, for cancellation by the subscriber | doOnCancel |
In addition to the preceding methods, there are the following methods:
- doOnEach: This method is executed for all publisher events raised in the stream processing. ...