{"id":19317485,"url":"https://github.com/rawsanj/spring-redis-websocket","last_synced_at":"2025-04-08T04:16:58.864Z","repository":{"id":50047107,"uuid":"123118175","full_name":"RawSanj/spring-redis-websocket","owner":"RawSanj","description":"Multi-instance Reactive WebSocket messaging Chat App demo using Spring Boot 3.x, Java 17 and Redis Pub/Sub","archived":false,"fork":false,"pushed_at":"2024-01-11T05:49:46.000Z","size":314,"stargazers_count":180,"open_issues_count":2,"forks_count":75,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-07T07:21:31.097Z","etag":null,"topics":["amd64","arm64","docker","graalvm","graalvm-native-image","heroku","java17","kubernetes","netty","reactive","reactive-web-sockets","redis","redis-pubsub","spring-boot","spring-data-redis","spring-native","spring-webflux","testcontainers","traefik","websocket"],"latest_commit_sha":null,"homepage":"https://chat.apps.dedyn.io","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RawSanj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-27T11:14:32.000Z","updated_at":"2025-04-01T15:16:18.000Z","dependencies_parsed_at":"2023-12-21T15:03:04.722Z","dependency_job_id":"dcf5d14c-bb6b-473d-abb5-38e24f82d009","html_url":"https://github.com/RawSanj/spring-redis-websocket","commit_stats":{"total_commits":111,"total_committers":1,"mean_commits":111.0,"dds":0.0,"last_synced_commit":"0048993f7ccd9fc091eb2b994af66bb7e1b4a021"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RawSanj%2Fspring-redis-websocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RawSanj%2Fspring-redis-websocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RawSanj%2Fspring-redis-websocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RawSanj%2Fspring-redis-websocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RawSanj","download_url":"https://codeload.github.com/RawSanj/spring-redis-websocket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247773721,"owners_count":20993639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amd64","arm64","docker","graalvm","graalvm-native-image","heroku","java17","kubernetes","netty","reactive","reactive-web-sockets","redis","redis-pubsub","spring-boot","spring-data-redis","spring-native","spring-webflux","testcontainers","traefik","websocket"],"created_at":"2024-11-10T01:15:17.487Z","updated_at":"2025-04-08T04:16:58.840Z","avatar_url":"https://github.com/RawSanj.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spring-redis-websocket\r\n\r\n[![Docker JVM Build](https://img.shields.io/github/actions/workflow/status/RawSanj/spring-redis-websocket/docker-jvm-image.yml?style=flat-square\u0026logo=docker\u0026label=jvm%20build)](https://github.com/RawSanj/spring-redis-websocket/actions/workflows/docker-jvm-image.yml)\r\n[![Docker GraalVM Native Build](https://img.shields.io/github/actions/workflow/status/RawSanj/spring-redis-websocket/docker-graalvm-native-image.yml?style=flat-square\u0026logo=docker\u0026label=graalvm%20build)](https://github.com/RawSanj/spring-redis-websocket/actions/workflows/docker-graalvm-native-image.yml)\r\n[![Docker Pulls](https://img.shields.io/docker/pulls/rawsanj/spring-redis-websocket?style=flat-square\u0026logo=docker\u0026color=orange)](https://hub.docker.com/repository/docker/rawsanj/spring-redis-websocket/general)\r\n[![Discord Server](https://img.shields.io/discord/465093591002513418?style=flat-square\u0026logo=discord\u0026label=discord)](https://discord.gg/4ebNhud)\r\n[![GitHub License](https://img.shields.io/github/license/rawsanj/spring-redis-websocket?style=flat-square\u0026logo=apache\u0026logoColor=red)](https://github.com/RawSanj/spring-redis-websocket?tab=Apache-2.0-1-ov-file)\r\n[![Spring Chat Website](https://img.shields.io/website?url=https%3A%2F%2Fchat.apps.dedyn.io%2Factuator%2Fhealth\u0026up_message=online\u0026up_color=green\u0026down_message=offline\u0026down_color=red\u0026style=flat-square\u0026logo=signal\u0026logoColor=white\u0026label=DEMO%20Chat\u0026labelColor=purple)](https://chat.apps.dedyn.io)\r\n\r\n## Multi-instance Reactive Chat App using Spring Boot WebFlux and Redis Pub/Sub\r\n\r\nScalable Java 17 Spring Boot 3.x WebFlux Chat Application to demonstrate use of Reactive Redis [Pub/Sub] using\r\nReactive [WebSocket Handler], without using any external Message Broker like RabbitMQ to sync messages between different\r\ninstances.\r\n\r\nBoth JVM based application and [GraalVM Native Image] is supported. \r\nAdditionally, the Docker Image for JVM base is available for AMD64 and ARM64 architecture. \r\n\r\n[![Deploy to Heroku](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy/?template=https://github.com/RawSanj/spring-redis-websocket/tree/spring-boot-web-2.3)\r\n\r\n\u003e The older non-reactive servlet based spring-redis-websocket application can be found in below:\r\n\u003e1. [Spring-Boot 2.3: Java-11 version](https://github.com/RawSanj/spring-redis-websocket/tree/spring-boot-web-2.3)\r\n\u003e2. [Spring-Boot 1.5: Java-8 version](https://github.com/RawSanj/spring-redis-websocket/tree/spring-boot-1.5.x)\r\n\r\n\u003e The older reactive spring-boot 2.x (java 11) based spring-redis-websocket application can be found in below:\r\n\u003e1. [Spring-Boot 2.4.6: Java-11 Reactive JVM \u0026 GraalVM Native version](https://github.com/RawSanj/spring-redis-websocket/tree/spring-boot-webflux-graal-native-2.4.6)\r\n\u003e2. [Spring-Boot 2.5.2: Java-11 Reactive JVM \u0026 GraalVM Native version](https://github.com/RawSanj/spring-redis-websocket/tree/spring-boot-webflux-graal-native-2.5.2)\r\n\r\n### Deploy to Play-with-Docker\r\n\r\nCtrl + Click this button to deploy multiple instances of the spring-redis-websocket load balanced by [Traefik]:\r\n\r\n[![Deploy to PWD](deploy-to-pwd.png)](https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/RawSanj/spring-redis-websocket/master/src/main/docker/docker-compose.yml)\r\n\r\n### Installation and Configuration\r\n\r\n##### Pre-requisite for Java Image:\r\nInstall and run [Redis] locally or on Docker.\r\n\r\nTo run Redis in Docker:\r\n```sh\r\n$ docker run -d -p 6379:6379 -e REDIS_PASSWORD=SuperSecretRedisPassword bitnami/redis:7.2.3\r\n```\r\n\r\n##### Pre-requisite for GraalVM Native Image:\r\nThis application uses Spring Data Redis APIs which doesn't have default GraalVM hints/config and graalvm-native image fails to run with errors.\r\n\r\nHence, this application is configured to use GraalVMVM native image tracing agent allows intercepting reflection, resources or proxy usage on the JVM by running simple Integration Tests which requires Redis.\r\n\r\n1. To run integration test which uses [Redis TestContainers](https://www.testcontainers.org/supported_docker_environment) so [Docker] should be configured properly to run [Testcontainers]\r\n2. You also need to install [GraalVMVM JDK](https://github.com/graalvm/graalvm-ce-builds/releases/tag/vm-22.3.0) and [native-image](https://www.graalvm.org/reference-manual/native-image) component:\r\n   ```sh\r\n   $ sdk install java 22.3.r17-nik         # Using [SDKMAN](https://sdkman.io/jdks) install GraalVMVM distribution of JDK\r\n   $ sdk use java 22.3.r17-nik\r\n   ```\r\n\r\n##### Clone repo:\r\n```sh\r\n$ git clone https://github.com/RawSanj/spring-redis-websocket.git\r\n```\r\n\r\n#### Build and Run the application:\r\n\r\nBuild and run the **spring-redis-websocket** application:\r\n```sh\r\n$ cd spring-redis-websocket\r\n\r\n$ mvn clean package\r\n\r\n$ mvn spring-boot:run\r\n```\r\n\r\n#### Build GraalVM Native Image of the application:\r\n\r\nBuild and run the **spring-redis-websocket** native image:\r\n```sh\r\n$ cd spring-redis-websocket\r\n\r\n$ mvn -Pnative clean package\r\n\r\n$ target/spring-redis-websocket # run the executable binary\r\n```\r\n\r\n\u003e **Note:** Above steps are applicable for Linux only and creates linux executable binary. To create Windows executable there are few additional set-ups required, follow this [Steps](https://www.graalvm.org/docs/getting-started/windows).\r\n\r\n### Run in Docker\r\n\r\n#### Build and run the *spring-redis-websocket* locally in Docker:\r\n\r\nBuild the JAR file:\r\n\r\n```sh\r\n$ mvn clean package\r\n```\r\n\r\nBuild Docker image:\r\n\r\n```sh\r\n$ mvn clean spring-boot:build-image\r\n```\r\n\r\nBuild GraalVM Native Docker image:\r\n\r\n```sh\r\n$ mvn -Pnative clean spring-boot:build-image\r\n```\r\n\r\nRun docker image:\r\n\r\n```sh\r\n$ docker run -d -p 8080:8080 rawsanj/spring-redis-websocket:3.2.0-jvm # JVM based Docker Image\r\n\r\n$ docker run -d -p 8080:8080 rawsanj/spring-redis-websocket:3.2.0-native  # GraalVM Native Image based Docker Image\r\n```\r\n\r\n#### Run multiple instances using docker-compose locally\r\n\r\nRun multiple instances of *spring-redis-websocket* locally load balanced via [Traefik] connected to redis container in Docker:\r\n\r\n```sh\r\n$ cd src/main/docker\r\n$ docker-compose up\r\n```\r\n\r\n#### Or try [Play with Docker] to quickly setup Docker and run in browser:\r\n1. Click Create Instance to quickly setup Docker host.\r\n2. Install git by running: \r\n\t```sh\r\n\t$ apk add git --no-cache\r\n\t```\r\n3. Clone the repository:\r\n\t```sh\r\n\t$ git clone https://github.com/RawSanj/spring-redis-websocket.git\r\n\t```\r\n4. Run multiple instances of *spring-redis-websocket*:\r\n\t```sh\r\n\t$ cd spring-redis-websocket/src/main/docker\r\n\t$ docker-compose up\r\n\t```\r\n\r\n### Run in Kubernetes\r\n\r\n#### Assuming you have a Kubernetes Cluster up and running locally:\r\n\r\n```sh\r\n$ kubectl apply -f src/main/k8s\r\n```\r\n\r\n#### Or try [Play with Kubernetes] to quickly setup a K8S cluster:\r\n1. Follow the instructions to create Kuberenetes cluster.\r\n2. Install git by running: \r\n\t```sh\r\n\t$ yum install git -y\r\n\t```\r\n3. Clone the repository:\r\n\t```sh\r\n\t$ git clone https://github.com/RawSanj/spring-redis-websocket.git\r\n\t```\r\n4. Run multiple instances of *spring-redis-websocket* load balanced by native Kubernetes Service. All instances\r\n   connected to a single [Redis] pod.\r\n\t```sh\r\n\t$ cd spring-redis-websocket\r\n\t$ kubectl apply -f src/main/k8s\r\n\t```\r\n### Tech\r\n\r\n**spring-redis-websocket** uses a number of open source projects:\r\n\r\n* [Spring Boot] - An opinionated framework for building production-ready Spring applications. It favors convention over\r\n  configuration and is designed to get you up and running as quickly as possible.\r\n* [Spring Data Redis] - Spring Data Redis provides easy configuration and access to Redis from Spring applications.\r\n* [GraalVM Native Image] - Native Image is a technology to ahead-of-time compile Java code to a standalone executable,\r\n  called a native image.\r\n* [Redis] - Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and\r\n  message broker.\r\n* [Testcontainers] - Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway\r\n  instances of common databases or anything else that can run in a Docker container.\r\n* [Bootstrap] - Bootstrap is an open source toolkit for developing with HTML, CSS, and JS. Custom Bootstrap theme\r\n\t- [Bootswatch Sketch].\r\n* [Docker] - Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications.\r\n* [Traefik] - Traefik is a Cloud Native Application Proxy - Simplifies networking complexity while designing, deploying, and operating applications.\r\n* [Kubernetes] - Kubernetes is an open-source system for automating deployment, scaling, and management of containerized\r\n  applications.\r\n\r\nLicense\r\n----\r\n\r\nApache License 2.0\r\n\r\nCopyright (c) 2023 Sanjay Rawat\r\n\r\n[//]: #\r\n\r\n[Spring Boot]:\u003chttps://projects.spring.io/spring-boot\u003e\r\n\r\n[Redis]: \u003chttps://redis.io\u003e\r\n\r\n[Runtime]: \u003chttps://github.com/kubeless/kubeless/blob/master/docs/runtimes.md#custom-runtime-alpha\u003e\r\n\r\n[Spring Data Redis]: \u003chttps://projects.spring.io/spring-data-redis\u003e\r\n\r\n[GraalVM Native Image]: \u003chttps://www.graalvm.org/reference-manual/native-image\u003e\r\n\r\n[Testcontainers]: \u003chttps://www.testcontainers.org\u003e\r\n\r\n[Bootstrap]: \u003chttps://getbootstrap.com\u003e\r\n\r\n[Bootswatch Sketch]: \u003chttps://bootswatch.com/sketchy\u003e\r\n\r\n[Docker]: \u003chttps://www.docker.com\u003e\r\n\r\n[Traefik]: \u003chttps://traefik.io/traefik\u003e\r\n\r\n[Kubernetes]: \u003chttps://kubernetes.io\u003e\r\n\r\n[Pub/Sub]: \u003chttps://redis.io/topics/pubsub\u003e\r\n\r\n[WebSocket Handler]: \u003chttps://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-websockethandler\u003e\r\n\r\n[Play with Kubernetes]: \u003chttps://labs.play-with-k8s.com\u003e\r\n\r\n[Play with Docker]: \u003chttps://labs.play-with-docker.com\u003e\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frawsanj%2Fspring-redis-websocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frawsanj%2Fspring-redis-websocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frawsanj%2Fspring-redis-websocket/lists"}