Spring Boot WebFlux + Server-sent events example

In this article, we will show you how to develop a reactive web application, using Server-sent events Spring Boot 2.1.2.RELEASE Spring WebFlux 5.1.4.RELEASE Thymeleaf 3.0.11.RELEASE JUnit 5.3.2 Maven 3 In Spring, returns JSON and header MediaType.TEXT_EVENT_STREAM_VALUE @RestController public class CommentController { @GetMapping(path = "/comment/stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE) public Flux<Comment> feed() { //… } } In …

Read more

Spring WebFlux Test – Timeout on blocking read for 5000 MILLISECONDS

Test a Spring Webflux endpoint with the WebTestClient, and hits the following error messages. Is this possible to increase the timeout? java.lang.IllegalStateException: Timeout on blocking read for 5000 MILLISECONDS at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:117) at reactor.core.publisher.Mono.block(Mono.java:1524) at org.springframework.test.web.reactive.server.ExchangeResult.formatBody(ExchangeResult.java:247) at org.springframework.test.web.reactive.server.ExchangeResult.toString(ExchangeResult.java:216) at java.base/java.lang.String.valueOf(String.java:2788) at java.base/java.lang.StringBuilder.append(StringBuilder.java:135) at org.springframework.test.web.reactive.server.ExchangeResult.assertWithDiagnostics(ExchangeResult.java:200) Solution By default, the WebTestClient will be timeout after 5 seconds. We …

Read more