It is an example how to scale Spring Boot microservices based on a chat application.
- Move to
frontend/chatapp
dir - Run
npm install
- Run
npm run build
After that Spring will use build
dir as a source for static files.
- Build frontend
docker/docker-compose.yml
contains all necessary datasources (PostgreSQL, RabbitMQ, Redis). Run it withdocker-compose up -d
command.- Run backend with a command
./mvnw spring-boot:run -Dspring-boot.run.arguments=--server.port=8080
. Use different ports if you want to run multiple instances simultaneously. - Go to http://localhost:8080. Migrations will create 6 users: Neo, Boris Britva, Gendalf, Thor, Forrest Gump and Tyler Durden with
123
passwords.
- master branch contains initial state of the application that is not scalable.
- scalable branch contains fully-scalable application, using RabbitMQ as an external message broker, Redis for cache, and PostgreSQL for sessions.
- scalable-crazy branch contains an example of an approach to fix a problem of @SubscribeMapping in a BeanPostProcessor manner. It is fully-scalable, but has a huge disadvantage - every subscribed user gets an initial response.
- scalable-manual-shedlock branch shows how to use ShedLock manually without annotations.