Demo project for Spring Boot using Backpressure with MySQL.
- Kotlin
- Spring Boot
- SQS
This backpressure implementation checks the health status of the database. Such as "UP", "DOWN" or "OUT_OF_SERVICE".
This backpressure implementation monitors the number of connections in the database. If there are more than 30 connections the application will wait.
Check the number of active sessions in the database, if there are more than 100 sessions, the application will wait.
Run SQS and MySQL database using docker-compose:
docker-compose build --no-cache && docker-compose up -d
-Dspring.profiles.active=local
aws sqs send-message --queue-url http://localhost:4576/000000000000/sick-pokemon-queue --endpoint-url=http://localhost:4576 --message-body '{\"name\":\"Pikachu\",\"type\":\"ELECTRIC\",\"hp\":100,\"level\":50,\"master\":\"red\"}'
aws sqs send-message --queue-url http://localhost:4576/000000000000/sick-pokemon-queue --endpoint-url=http://localhost:4576 --message-body '{\"name\":\"Charizard\",\"type\":\"FIRE\",\"hp\":150,\"level\":65,\"master\":\"red\"}'
aws sqs send-message --queue-url http://localhost:4576/000000000000/sick-pokemon-queue --endpoint-url=http://localhost:4576 --message-body '{\"name\":\"Blastoise\",\"type\":\"WATER\",\"hp\":120,\"level\":60,\"master\":\"red\"}'
Or
#!/bin/bash
for ((i=1; i<=2; i++))
do
aws sqs send-message --queue-url http://localhost:4576/000000000000/sick-pokemon-queue --endpoint-url=http://localhost:4576 --message-body '{"name":"Pikachu","type":"ELECTRIC","hp":100,"level":50, "master": "red"}'
aws sqs send-message --queue-url http://localhost:4576/000000000000/sick-pokemon-queue --endpoint-url=http://localhost:4576 --message-body '{"name":"Charizard","type":"FIRE","hp":150,"level":65, "master": "red"}'
aws sqs send-message --queue-url http://localhost:4576/000000000000/sick-pokemon-queue --endpoint-url=http://localhost:4576 --message-body '{"name":"Blastoise","type":"WATER","hp":120,"level":60, "master": "red"}'
done