Implementation of rabbitmq with asynqp
Project description
===============
rabbitmq_asynqp
===============
Usage:
======
* Both producer and consumer:
-----------------------------
rabbitmq_asynqp provides you ability to use rabbitmq messaging asynchronous non-blocking way by the use of asynqp and
asyncio with just few lines of code. Typical usage will be like this:
from rabbitmq_asynqp.messaging import Messaging
rabbitmq_config = dict(host="localhost", port=5672, username="guest", password="guest")
queue_config = dict(
exchange="sample_exchange",
queues=["sample_queue1"],
routing_key="sample.routing_key",
exchange_type="direct",
error_messaging=dict(
exchange="error_exchange",
queues=["error_queue"],
routing_key="error.key",
exchange_type="direct",
)
)
def consumer_func(message: dict):
# define your consumer func
pass
messaging = Messaging(rabbitmq_config: dict, queue_config: dict, consumer_func)
use this messaging object globally for sending message like this:
messaging.send_message(message) # To send single message
messaging.send_messages(messages) # To send multiple bulk messages
* Only Consumer:
----------------
To run only consumer use a separate thread or process and do following:
from rabbitmq_asynqp.messaging import Consumer
rabbitmq_config = dict(host="localhost", port=5672, username="guest", password="guest")
queue = "queue_name"
def consumer_func(*args, **kwargs):
# define your consumer func
pass
consumer = Consumer(rabbitmq_config, queue, consumer_func)
consumer()
* Only Producer:
----------------
To run producer only for message production:
from rabbitmq_asynqp.messaging import Producer
rabbitmq_config = dict(host="localhost", port=5672, username="guest", password="guest")
queue_config = dict(
exchange="sample_exchange",
queues=["sample_queue1"],
routing_key="sample.routing_key",
exchange_type="direct",
error_messaging=dict(
exchange="error_exchange",
queues=["error_queue"],
routing_key="error.key",
exchange_type="direct",
)
)
producer = Producer(rabbitmq_config, queue_config)
producer.send_msg(message)
Message sent must be dict.
For any queries, mail to akshay2agarwal@gmail.com
rabbitmq_asynqp
===============
Usage:
======
* Both producer and consumer:
-----------------------------
rabbitmq_asynqp provides you ability to use rabbitmq messaging asynchronous non-blocking way by the use of asynqp and
asyncio with just few lines of code. Typical usage will be like this:
from rabbitmq_asynqp.messaging import Messaging
rabbitmq_config = dict(host="localhost", port=5672, username="guest", password="guest")
queue_config = dict(
exchange="sample_exchange",
queues=["sample_queue1"],
routing_key="sample.routing_key",
exchange_type="direct",
error_messaging=dict(
exchange="error_exchange",
queues=["error_queue"],
routing_key="error.key",
exchange_type="direct",
)
)
def consumer_func(message: dict):
# define your consumer func
pass
messaging = Messaging(rabbitmq_config: dict, queue_config: dict, consumer_func)
use this messaging object globally for sending message like this:
messaging.send_message(message) # To send single message
messaging.send_messages(messages) # To send multiple bulk messages
* Only Consumer:
----------------
To run only consumer use a separate thread or process and do following:
from rabbitmq_asynqp.messaging import Consumer
rabbitmq_config = dict(host="localhost", port=5672, username="guest", password="guest")
queue = "queue_name"
def consumer_func(*args, **kwargs):
# define your consumer func
pass
consumer = Consumer(rabbitmq_config, queue, consumer_func)
consumer()
* Only Producer:
----------------
To run producer only for message production:
from rabbitmq_asynqp.messaging import Producer
rabbitmq_config = dict(host="localhost", port=5672, username="guest", password="guest")
queue_config = dict(
exchange="sample_exchange",
queues=["sample_queue1"],
routing_key="sample.routing_key",
exchange_type="direct",
error_messaging=dict(
exchange="error_exchange",
queues=["error_queue"],
routing_key="error.key",
exchange_type="direct",
)
)
producer = Producer(rabbitmq_config, queue_config)
producer.send_msg(message)
Message sent must be dict.
For any queries, mail to akshay2agarwal@gmail.com
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
rabbitmq_asynqp-0.1.0.tar.gz
(5.0 kB
view hashes)
Built Distribution
Close
Hashes for rabbitmq_asynqp-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4beacd778a270c432498bed61799d3cdddd6cdbd91223c9b85c3ba97600f39e9 |
|
MD5 | 3a6d3f7c6043c5d91e8f5945ad55a9bf |
|
BLAKE2b-256 | aead5e511080e5ae1d671b921468d8e3c92586ea56f76fba321336c1a080cca2 |