My understanding is that when a Mono is subscribed to the first signal is doOnNext then doOnSuccess and then doOnTerminate however when I run the below code the sequence of execution of these methods is the sequence in which they have been chained, i.e doOnTerminate, doOnSuccess, doOnNext. If I change the sequence of chaining the sequence also get changed.
@Test
public void doOnsMono(){
Mono<String> mono = Mono.just("ABC");
mono.doOnSubscribe(s -> System.out.println("Just got subscribed") )
.doOnTerminate(() -> System.out.println("Termination happens at the end"))
.doOnSuccess(s -> System.out.println("I am successfull " + s))
.doOnNext(s -> System.out.println("next next next" + s))
.subscribe(s -> System.out.println("Subscribe" + s));
}
Output is such Just got subscribed
Termination happens at the end
I am successfull ABC
next next nextABC
SubscribeABC
Can someone please explain this behavior or the gap in my understanding.