Pub-Sub with RabbitMQ and Mosquitto Broker. These code were tested under python 3.10.6 (with setuptools 59.6.0 & pip 22.0.2).
git clone git@github.com:engrjislam/pub_sub_with_rabbitmq_and_mosquitto.git
cd pub_sub_with_rabbitmq_and_mosquitto
This repository requires paho-mqtt (1.6.1) and pika (1.3.1). Let's install in python virtual environment.
python3 -m venv vPy3
source vPy3/bin/activate
pip install pika==1.3.1 paho-mqtt==1.6.1
Data can be generated either by broker/producer.py or pub/src/publish.py.
python broker/producer.py
It is required to run eighter of producer/consumer at least once to bind topic/routing_key with the exchange brfore running follwing command.
python pub/src/publish.py
Data can be consumed either by broker/consumer.py or pub/src/subscribe.py.
python broker/consumer.py
Following approach will not grab data from a queue that were used to store data. So earlier data will be discarded (but they will be in the queue).
python sub/src/subscribe.py