Spring Redis Websocket

Multi-instance WebSocket messaging demo using Spring Boot and Redis Pub/Sub

Scalable Spring Boot Chat Application to demonstrate use of [Redis] - [Pub/Sub] for [WebSocket using STOMP] protocol, without using any external Message Broker like RabbitMQ to sync messages between different instances.

Deploy to [Play with Docker]

Ctrl + Click the below button to deploy multiple instances of the spring-redis-websocket load balanced by NGINX:

Deploy to PWD

Installation and Configuration


Install and run [Redis] locally or on Docker.

To run Redis in Docker:

$ docker run -d -p 6379:6379 -e REDIS_PASSWORD=SuperSecretRedisPassword bitnami/redis
Clone repo:
$ git clone https://github.com/RawSanj/spring-redis-websocket.git

Build and Run the applications:

Build and run the spring-redis-websocket application:

$ cd spring-redis-websocket

$ mvn clean package

$ mvn spring-boot:run

Run in Docker

Build and run the spring-redis-websocket locally in Docker:

Build the JAR file:

$ mvn clean package

Build docker image:

$ mvn docker:build

Run docker image:

$ docker run -d -p 8080:8080 \
$ rawsanj/spring-redis-websocket

Run multiple instance using docker-compose locally

Run multiple instances of spring-redis-websocket locally load balanced via Ngnix connected to redis container in Docker:

$ cd src/main/docker
$ docker-compose up

Run in Kubernetes

Assuming you have a Kubernetes Cluster up and running locally:

$ kubectl apply -f src/main/k8s
Sanjay Rawat
Cloud Developer

I’m interested in all Cloud Tech - AWS, Serverless, Docker, Kubernetes. Mostly write Java, Spring, Kotlin and Node.js code.


Docker Deep Dive for Java Developers

Kubernetes for Java Developers