RabbitMQ Consumer/Publisher client

Posted by FourierMourier@reddit | Python | View on Reddit | 0 comments

About
Hello there! I've written a simple RabbitMQ client in python that lets you switch between publisher and consumer modes, with customizable options. You might find it useful for experimenting with RabbitMQ message flow or simple stress testing.

What My Project Does
The client can publish or consume messages with parameters set via CLI arguments or environment variables.
You can set different modes (publisher or consumer) and manage the message flow.

Examples
Here are two basic examples of the logs you get when running the client in publisher and consumer modes:

$ docker run --rm --env-file .env fouriermourier/py_rmq_client:latest rmq --mode=publisher --message="hello there" --delay=0.6 --log-level=warning --verbose=True

Logs:

Starting publisher with 0.6s delay between message processing
[x] 2024-09-07 13:51:35.204848: Published message: hello there, to Exchange:
[x] 2024-09-07 13:51:35.805139: Published 1 messages
[x] 2024-09-07 13:51:36.621080: Published message: hello there, to Exchange:
...

$ docker run --rm --env-file .env fouriermourier/py_rmq_client:latest rmq --mode=consumer --delay=0.5 --log-level=warning --verbose=True

Logs:

Starting consumer with 0.5s delay between message processing
[*] Waiting for messages. To exit press CTRL+C
[x] 2024-09-07 13:51:35.296454: Received: b'hello there', Exchange: '', Routing Key: tmp_queue1
[x] 2024-09-07 13:51:36.705185: Received: b'hello there', Exchange: '', Routing Key: tmp_queue1
...

Target Audience
This project is for developers looking to test and explore RabbitMQ configurations quickly within Docker environments or anyone working with RabbitMQ who needs a simple and configurable client to test message flows.

Source
Source code is available here: https://github.com/FourierMourier/py_rmq_client
There you can find additional info regarding environment variables or CLI arguments and docker-compose examples.

Future Plans
Any suggestions are always welcome!