rabbitqm-alphamoon
pika-based RabbitMQ connector with built in JSON serialization/deserialization
Features
- publishing:
publish(message) - getting number of messages in the queue:
message_count - consuming (forever, i.e. with a callback function):
consume_forever(callback_fun) - setting up a dead letter exchange (number of retries passed to the consumer in the
infoargument)
See code examples in the "Examples" section.
Requirements
pika==1.2.0
Installation
You can install "rabbitmq-alphamoon" via pip from PyPI:
$ pip install rabbitmq-alphamoon
Examples
Initialization
import pika
from rabbitmq_alphamoon import RabbitMQConnector
parameters = pika.ConnectionParameters(
host=rabbitmq_host,
port=rabbitmq_port,
credentials=pika.PlainCredentials(
username=rabbitmq_username,
password=rabbitmq_password,
),
)
queue = RabbitMQConnector(
connection_parameters=parameters,
queue=queue_name,
)
Publishing
message = {'foo': 'bar'}
with queue.open_connection():
queue.publish(message)
Getting a number of the messages in the queue
message_count = queue.message_count
Consuming
def process_message(message, info):
print(message)
print(info)
with queue.open_connection():
queue.consume_forever(process_message_callback=process_message)
Short form for one-time usage of connector
If you do not need to reuse the connector, you can initialize and open connection without assignment of connector to a variable before calling open_connection context manager. This may come in handy especially in case of consuming, where connector is usually used only to call consume_forever function.
with RabbitMQConnector(
connection_parameters=parameters,
queue=queue_name,
).open_connection() as queue:
queue.consume_forever(process_message_callback=process_message)
Contributing
Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.
License
Distributed under the terms of the MIT license, "rabbitmq-alphamoon" is free and open source software
Issues
If you encounter any problems, please email us at dev@alphamoon.ai, along with a detailed description.
Release files for rabbitmq-alphamoon 0.8.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 | |
|---|---|---|---|
| rabbitmq-alphamoon-0.8.3.tar.gz | 9.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rabbitmq_alphamoon-0.8.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.9 kB
Release files / rabbitmq-alphamoon-0.8.3.tar.gz
| Download URL | rabbitmq-alphamoon-0.8.3.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
844c0452059fdd22a55ee13ee8c7fa1630e1fc30495f70f7b2b60c087fe6d8d4
|
|
BLAKE2b-256 checksum How to use checksums |
8ac7786c94f954bd0a4ff9dfadbaf416962de74062f3b419ce8542e689b2c4d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10
|
Release files / rabbitmq_alphamoon-0.8.3-py3-none-any.whl
| Download URL | rabbitmq_alphamoon-0.8.3-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
256bf26d8ea7c977c20b1da929c60df089d962dead506fb81e5a417f0d8265f1
|
|
BLAKE2b-256 checksum How to use checksums |
b6e32f983572e141d8586ff9a57df2a261232647ea54f9dd7ec78f9072b73bfc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10
|