Skip to content

Commit

Permalink
Move blocking publishChatMessage operation to boundedElastic thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Arooba-git committed Jul 14, 2023
1 parent d68ec34 commit 93894bf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/com/github/rawsanj/handler/WebHttpHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.scheduler.Schedulers;

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

}

}

0 comments on commit 93894bf

Please sign in to comment.