Just like its predecessors, Spring 5 supports a high-frequency but low-latency data exchange between a client and a server using a websocket
protocol. This recipe will just provide a step-by-step procedure on how to implement raw and real-time WebSocket messaging without using any third-party brokers.
Create a new Maven project, ch12-websocket
, that will implement the simple and non-reactive TextSocketWebHandler
to entertain complaints from clients.
Let us create a simple messenger by performing the following steps:
- First, convert
ch12-websocket
to the Spring Boot 2.0 application by topom.xml
the Spring Boot 2.0.0.M2 starter POM dependencies, such as Spring WebFlux for Reactive components and Spring Boot actuator for project status monitoring and management. - To add support for the
websocket
protocol, add the following starter POM dependency inpom.xml
:
<dependency> <groupId>org.springframework.boot...