An open API service indexing awesome lists of open source software.

https://github.com/jonathan-foucher/spring-boot-redis-topic-example

An example of Redis pub/sub on Spring Boot
https://github.com/jonathan-foucher/spring-boot-redis-topic-example

java redis-pubsub spring-boot valkey

Last synced: 4 months ago
JSON representation

An example of Redis pub/sub on Spring Boot

Awesome Lists containing this project

README

          

## Introduction
This project is an example of Redis / Valkey pub/sub implementation with Spring Boot.

An endpoint allows to post a job in the queue and the subscriber will automatically consume it.
The publisher and subscriber are both set on the same project on this example.

Note that all the jobs will run in parallel when the message is received by the subscriber.
If you need to wait for the current job to end before launching the next one, Redis / Valkey Stream might be a better solution and you can check [this project](https://github.com/jonathan-foucher/spring-boot-redis-stream-example).

## Run the project
Valkey is a free open-source project forked from Redis.
If you prefer, you can choose to run Redis instead.

You will need to launch a Valkey instance on your computer before running the project.

You can either install Valkey directly on your machine or run it through Docker :
`docker run -p 6379:6379 valkey/valkey`

Once Valkey 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-topic-example/v1/jobs/start \
--header 'Content-Type: application/json' \
--data '{"id": 1, "name": "some job name"}'
```