You can checkout the live version of the application at https://spring-ws-chat.herokuapp.com/
-
Java - 11
-
Maven - 3.x.x
1. Clone the application
git clone https://github.com/callicoder/spring-boot-websocket-chat-demo.git
2. Build and run the app using maven
cd spring-boot-websocket-chat-demo
mvn package
java -jar target/websocket-demo-0.0.1-SNAPSHOT.jar
Alternatively, you can run the app directly without packaging it like so -
mvn spring-boot:run
You can find the tutorial for this application on my blog -
https://www.callicoder.com/spring-boot-websocket-chat-example/
- https://blog.scaleway.com/iot-hub-what-use-case-for-websockets/
- https://medium.com/ballerina-techblog/go-real-time-with-ballerina-websockets-58c40ac11d6
- https://www.educba.com/mqtt-vs-websocket/
For those reading of you who simply want to know if you should choose WebSockets or REST for your next project, here’s a simple rule: if any of the following sounds like your application, then use WebSockets. If not, stick to traditional HTTP/REST requests:
- Real-time collaboration (Google Docs, Easybase)
- Social feeds (Twitter, Discord)
- Image/text chat (Messenger, Snapchat)
- Synchronizing across multiple sessions (Todoist, Dropbox)
- News/score updates (ESPN, CBS Sports)
- Multiplayer game (Lichess)
STOMP which stands for Simple/Streaming Text Oriented Messaging Protocol is a sub protocol which runs on top of Websocket connections and is used for message exchanges between clients via an intermediate message broker.
STOMP has client implementations in different languages such as in Javascript(stomp-js) and Java, to interact with a Springboot Server over websockets. Do go through this amazing article to understand how Springboot over websockets with STOMP works.
Now let us go over building a python client with the required springboot server configurations for interactions between the two.
Check image tags on DockerHub
docker pull pcloud/rabbitmq-stomp
docker container run -it --name rabbitmq-stomp -p 15672:15672 -p 5672:5672 -p 61613:61613 pcloud/rabbitmq-stomp
- RabbitMQ Web UI: localhost:15672
- Credential RabbitMQ:
admin/admin
- Credential STOMP:
admin/admin
5672
: Default port of RabbitMQ15672
: RabbitMQ Web UI61613
: STOMP port