WebSocket is a thin and lightweight layer above TCP, suitable for embed messages. As communication protocol, WebSocket provided a bi-directional, full-duplex, and persistent connection between two machines. Once a WebSocket connection is established, the connection stays open until the connection is closed. Check here for the differences between normal HTTP connection and WebSocket.

WebSocket is very suitable for web applications where the client and server need to exchange messages at high frequency but with low latency. As example is trading application in financial industry, which is very time sensitive. Another type of applications including collaboration tools (like chat application) and games.

Spring Framework introducing spring-websocket module since version 4, with comprehensive WebSocket support. This module is not only compatible with the Java WebSocket API standard, but also provides additional value-add. This is included a set of annotations and key abstractions from the Spring Integration project such as Message, MessageChannel, MessageHandler, and many others.

Tutorials in this series:

Related series:

  • Getting Started With Spring Boot

    Spring Boot is a project built on the top of the Spring framework. It provides a simpler and faster way to set up, configure, and run applications.