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.
Metadata
Release files for msgbuzz 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| msgbuzz-0.1.3.tar.gz | 5.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| msgbuzz-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.0 kB
Release files / msgbuzz-0.1.3.tar.gz
| Download URL | msgbuzz-0.1.3.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f435b2223b26eaebf5e8902146925e70ed01d0fd3f59063bf8b740ebfac3dee
|
|
BLAKE2b-256 checksum How to use checksums |
41358db08d6302235b44e47340ca6f00d6fe93207888dcd0f75163a124280304
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|
Release files / msgbuzz-0.1.3-py3-none-any.whl
| Download URL | msgbuzz-0.1.3-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9e0f69c5b47d3bfd95522a44c79d47c4190453f07ef4b84c441c0ff82b45de76
|
|
BLAKE2b-256 checksum How to use checksums |
c95b11a71c8a33efa2681d65bf65a852589102af16cd6394f0e28040bf25fa88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|