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("{} was completed!", chatRoom))
- .doOnError(throwalbe -> log.error("{} failed: {}", chatRoom, throwalbe));
+ .doOnError(throwalbe -> log.error("{} failed: {}", chatRoom, throwalbe))
+ .thenMany(Flux.defer(() -> receiveMessages(chatRoom)));
}
Flux<ServerSentEvent<String>> receiveServerSentEvents(ChatRoomInfoTo chatRoom)
chatRoom.getId())
.accept(MediaType.TEXT_EVENT_STREAM)
.retrieve()
- .bodyToFlux(SSE_TYPE);
+ .bodyToFlux(SSE_TYPE)
+ .retryWhen(Retry.fixedDelay(15, Duration.ofSeconds(1)));
}