'RxJava message on successful retry

How can I print message on successful retry while using retryWhen operator?

Let's say I have

Flowable.defer(() -> subscribe())
        .retryWhen(error -> error.delay(5, TimeUnit.SECONDS))
        .subscribe(s -> ....)

subscribe() method returns Flowable which may contains error. I'd like print message "subscribed" when it finally succeeds.



Solution 1:[1]

Does this work?

Flowable.defer(() -> subscribe())
        .retryWhen(error -> error.delay(5, TimeUnit.SECONDS))
        .doOnComplete(() -> System.out.println("Success!"))
        .subscribe(s -> ....)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sli