Skip to content

sanogotech/spring-boot-websocket-chat-demo

 
 

Repository files navigation

Spring Boot WebSocket Chat Appplication

You can checkout the live version of the application at https://spring-ws-chat.herokuapp.com/

App Screenshot

Requirements

  1. Java - 11

  2. Maven - 3.x.x

Steps to Setup

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

Learn More

You can find the tutorial for this application on my blog -

https://www.callicoder.com/spring-boot-websocket-chat-example/

Docs

Uses Cases

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

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.

RabbitMQ docker image with STOMP plugin enable

ci Docker Stars Docker Pulls

Check image tags on DockerHub

Quick start

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

Exposed ports

  • 5672: Default port of RabbitMQ
  • 15672: RabbitMQ Web UI
  • 61613: STOMP port

Releases

No releases published

Packages

No packages published

Languages

  • Java 31.8%
  • CSS 30.3%
  • JavaScript 22.3%
  • HTML 12.3%
  • Dockerfile 3.3%