A Spring Boot demo project for storing simple logs to a database. All logs are connected to a "device".
The service listens for incoming events (Redis queue) and stores them. Each log entry is connected to a device and a log type.
A REST API is provided to query for logs.
at /swagger-ui.html
.
at /api/<resource>
. E.g. http://localhost:5010/api/logs
The service connects to a Postgres DB and a Redis cluster.
-
Make sure you have Java 21 installed as this is the default version when building and when running the service (in docker).
-
Make sure Docker is installed locally.
-
Build locally with maven
mvn clean install
. -
Run the backend service. This can be done in one of the following ways:
- Run directly from your IDE with the spring profile
local
enabled.- NOTE: The service depends on having both a database- and a Redis-connection. Therefore, both a Redis instance and a database needs to be running. This can be achieved by running these parts in Docker, with command
docker compose up simple-log-db simple-log-redis
- NOTE: The service depends on having both a database- and a Redis-connection. Therefore, both a Redis instance and a database needs to be running. This can be achieved by running these parts in Docker, with command
- Run the complete system from docker with
docker compose up --build
. The profiledocker
is automatically enabled.
- Run directly from your IDE with the spring profile
-
Access API with
http://localhost:5010
Under folder /scripts/redis_message_trigger a support script is available that can be used to publish Redis messages to the device-activity channel, which the simple-log-service subscribes to. This allows for easy testing of the system. Check the README.md in the folder for more information.