Generic message bus abstraction. Supported implementation: RabbitMQ through Pika
Project description
Msgbuzz
Generic message bus abstraction. Supported implementations: RabbitMQ
Build Status
TODO
Usage
Instantiate msgbuzz.rabbitmq.RabbitMqMessageBus to start publishing and consuming.
Publishing to topic
Publish new message to profile.new topic
from msgbuzz.rabbitmq import RabbitMqMessageBus
if __name__ == '__main__':
msg_bus = RabbitMqMessageBus(host='localhost')
for i in range(2):
msg_bus.publish('profile.new', f'Message {i + 1} !!'.encode())
Subscribing to topic
Subscribe for profile.new topic and print the message.
Note:
Don't forget to ack() or nack() the message
import time
from msgbuzz import ConsumerConfirm
from msgbuzz.rabbitmq import RabbitMqMessageBus
def print_message(op: ConsumerConfirm, message: bytes):
print(f"{message}")
time.sleep(2)
op.ack()
if __name__ == '__main__':
msg_broker = RabbitMqMessageBus(host='localhost')
msg_broker.on("profile.new", 'job-norm', print_message)
msg_broker.start_consuming()
Please mind that on every subscription msgbuzz will span new child process.
Scaling Subscriber
Increase number of consumers of each subscription to improve performance. You do this by:
- Running the subscriber file (ex: receiver.py in above example) multiple times.
- Use Supervisord and set numprocs to number larger than one.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file msgbuzz-0.1.3.tar.gz.
File metadata
- Download URL: msgbuzz-0.1.3.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f435b2223b26eaebf5e8902146925e70ed01d0fd3f59063bf8b740ebfac3dee
|
|
| MD5 |
2ab52a47c6e4e92192079db3d66bc46b
|
|
| BLAKE2b-256 |
41358db08d6302235b44e47340ca6f00d6fe93207888dcd0f75163a124280304
|
File details
Details for the file msgbuzz-0.1.3-py3-none-any.whl.
File metadata
- Download URL: msgbuzz-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e0f69c5b47d3bfd95522a44c79d47c4190453f07ef4b84c441c0ff82b45de76
|
|
| MD5 |
d62216469e69fedca9fa21c0ffb307c2
|
|
| BLAKE2b-256 |
c95b11a71c8a33efa2681d65bf65a852589102af16cd6394f0e28040bf25fa88
|