package org.javacodegeeks.examples.v3.retry;

import reactor.core.publisher.Flux;
import reactor.core.scheduler.Schedulers;

public class RetrySimpleMain {
    public static void main(String[] args) {
        Flux.just(1, 2, 3, 4, 5, 6)
            .doOnNext(i -> {
                if (i != 3) {
                    System.out.printf("[%s] Got %s\n", Thread.currentThread().getName(), i);
                } else {
                    System.out.printf("[%s] Got illegal %s\n", Thread.currentThread().getName(), i);
                    throw new IllegalStateException("Got illegal 3");
                }
            })
            .retry(2)
            .subscribeOn(Schedulers.boundedElastic())
            .blockLast();
    }
}
