2023-07-12 10:37:31 +02:00
2023-07-03 09:09:06 +02:00
2023-07-03 09:09:06 +02:00
2023-07-12 09:06:05 +02:00

redis-queueing-sample

This repo aims to show how to communicate between two services using Redis as a message broker with pub/sub channels.

How it works ?

                                           ┌────────────┐
                                           │server      │
                           ┌───────────────►            │
                           │               │            │
                           │               │            │
┌────────────┐       ┌─────┴──────┐        │            │
│client      │       │redis       │        └────────────┘
│            │       │            │
│            ├───────►            │
│            │       │            │
│            │       │:6379       │        ┌────────────┐
└────────────┘       └─────┬──────┘        │server      │
                           │               │            │
                           │               │            │
                           │               │            │
                           └───────────────►            │
                                           └────────────┘
  • A client publish a message to the Redis channel
  • Servers subscribe to the channel and handle the message

Run

  • Start Redis and the server
make run
  • Publish messages with the client
make run-client

You should see the following server logs:

listening message...
Received data: Message { id: 1, action: Download }
Received data: Message { id: 1, action: Download }
Received data: Message { id: 1, action: Download }
Received data: Message { id: 1, action: Download }
Received data: Message { id: 1, action: Download }
Received data: Message { id: 1, action: Download }
Received data: Message { id: 1, action: Download }
Description
This repo aims to show how to communicate between two services using Redis as a message broker with pub/sub channels. Yes, queueing in the title is inappropriate...
Readme 30 KiB
Languages
Rust 81.4%
Makefile 18.6%