https://github.com/jonathan-foucher/spring-boot-redis-stream-example
An example of queueing jobs with a redis stream
https://github.com/jonathan-foucher/spring-boot-redis-stream-example
java queued-jobs redis-stream spring-boot
Last synced: 9 days ago
JSON representation
An example of queueing jobs with a redis stream
- Host: GitHub
- URL: https://github.com/jonathan-foucher/spring-boot-redis-stream-example
- Owner: jonathan-foucher
- Created: 2024-07-06T18:47:29.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-19T15:10:31.000Z (12 months ago)
- Last Synced: 2024-11-26T14:12:46.718Z (11 months ago)
- Topics: java, queued-jobs, redis-stream, spring-boot
- Language: Java
- Homepage:
- Size: 25.4 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Introduction
This project is an example of Redis stream implementation with Spring Boot.The objective is to create a queue for jobs to be processed one by one in the produced order.
If the app restart, it must process the job that was currently active and continue.
The app should also be able to return what jobs are currently queued and not allow to add an already queued job.An endpoint allows to post a job in the queue and the consumer will automatically process it.
The producer and consumer are both set on the same project on this example.## Run the project
You will need to launch a Redis instance on your computer before running the project.You can either install Redis directly on your machine or run it through Docker :
`docker run -p 6379:6379 redis`Once Redis is launched, you can start the Spring Boot project and start posting HTTP requests on the endpoint:
```
curl --request POST \
--url http://localhost:8080/redis-stream-example/v1/jobs/start \
--header 'Content-Type: application/json' \
--data '{"id": 1, "name": "some job name"}'
```There is also an endpoint to retrieve all queued jobs ids:
```
curl --request GET \
--url http://localhost:8080/redis-stream-example/v1/jobs/queued
```A custom health checker was added to check if the stream subscription is still active
It might be inactive when connection to redis is lost and won't recover the subscription
```
curl --request GET \
--url http://localhost:8080/redis-stream-example/actuator/health
```