Skip to content

Commit 93894bf

Browse files
committed
Move blocking publishChatMessage operation to boundedElastic thread
1 parent d68ec34 commit 93894bf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/com/github/rawsanj/handler/WebHttpHandler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.springframework.http.MediaType;
1010
import org.springframework.web.reactive.function.server.RouterFunction;
1111
import org.springframework.web.reactive.function.server.ServerResponse;
12+
import reactor.core.scheduler.Schedulers;
1213

1314
import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
1415
import static org.springframework.web.reactive.function.server.RequestPredicates.POST;
@@ -23,7 +24,9 @@ public RouterFunction<ServerResponse> htmlRouter(@Value("classpath:/static/index
2324
return route(GET("/"), request -> ok().contentType(MediaType.TEXT_HTML).bodyValue(html))
2425
.andRoute(POST("/message"), request -> request.bodyToMono(Message.class)
2526
.flatMap(message -> redisChatMessagePublisher.publishChatMessage(message.getMessage()))
26-
.flatMap(aLong -> ServerResponse.ok().bodyValue(new Message("Message Sent Successfully!."))));
27+
.flatMap(aLong -> ServerResponse.ok().bodyValue(new Message("Message Sent Successfully!.")))
28+
.subscribeOn(Schedulers.boundedElastic()));
29+
2730
}
2831

2932
}

0 commit comments

Comments
 (0)