import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
+import reactor.util.retry.Retry;
+import java.time.Duration;
import java.util.*;
})
.doOnNext(message -> list.add(message))
.doOnComplete(() -> log.info("Listening to {} was completed!", chatRoom))
- .doOnError(throwalbe -> log.error("Listening to {} failed!", chatRoom, throwalbe));
+ .doOnError(throwalbe -> log.error("Listening to {} failed!", chatRoom, throwalbe))
+ .thenMany(Flux.defer(() -> receiveMessages(chatRoom)));
}
Flux<ServerSentEvent<String>> receiveServerSentEvents(ChatRoomInfoTo chatRoom)
.accept(MediaType.TEXT_EVENT_STREAM)
.header("X-Shard", chatRoom.getShard().toString())
.retrieve()
- .bodyToFlux(SSE_TYPE);
+ .bodyToFlux(SSE_TYPE)
+ .retryWhen(Retry.fixedDelay(15, Duration.ofSeconds(1)));
}