Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ateliedocodigo/py-queue-manager
Library to deal with RabbitMQ
https://github.com/ateliedocodigo/py-queue-manager
hacktoberfest pika python python3 rabbitmq
Last synced: about 2 months ago
JSON representation
Library to deal with RabbitMQ
- Host: GitHub
- URL: https://github.com/ateliedocodigo/py-queue-manager
- Owner: ateliedocodigo
- Created: 2017-06-08T00:08:24.000Z (over 7 years ago)
- Default Branch: develop
- Last Pushed: 2022-07-21T14:33:16.000Z (over 2 years ago)
- Last Synced: 2024-10-11T19:36:57.315Z (3 months ago)
- Topics: hacktoberfest, pika, python, python3, rabbitmq
- Language: Python
- Homepage:
- Size: 70.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG-legacy.md
Awesome Lists containing this project
README
py-queue-manager
================.. image:: https://badge.fury.io/py/pyqueuemanager.svg
:target: https://badge.fury.io/py/pyqueuemanagerLibrary to deal with RabbitMQ and Google PubSub
Usage
-----QueueManager class
.................... code:: python
>>> from queue_manager.queue_manager import QueueManager
>>> conn_params = {
... 'host': '',
... 'port': '',
... 'username': '',
... 'password': ''
... }
>>> # or use multiple urls
>>> conn_params = ('amqp://host1', 'amqp://host2',)
qm = QueueManager(conn_params)
>>> qm.push('hello', 'Hello from QueueManager')
True
>>> qm.pop('hello')
Hello from QueueManager
>>> del(qm)RabbitMqPublisher class
......................... code:: python
from queue_manager.rabbitmq_consumer import RabbitMqPublisher
producer = RabbitMqPublisher('amqp://username:*****@hostname:port',
'exchange', 'exchange_type', 'queue_name', 'routing_key')producer.publish_message('hello')
# or passing message property
producer.publish_message('hello', dict(priority=8))RabbitMqConsumer class
......................This class is an async consumer class, that still connected.
Inspired on: asynchronous_consumer_example_
.. code:: python
single_url = 'amqp://username:*****@hostname:port'
# or multiple urls
multiple_urls = ('amqp://username:*****@hostnameone:port', 'amqp://username:*****@hostnametwo:port')
consumer = RabbitMqConsumer(single_url, queue='queue_name')try:
def callback(body):
print("message body", body)consumer.run(callback)
except KeyboardInterrupt:
consumer.stop()TornadoConsumer class
......................... code:: python
from tornado.ioloop import IOLoop
from queue_manager.tornado_consumer import TornadoConsumerconsumer = TornadoConsumer('amqp://username:*****@hostname:port',
'exchange', 'exchange_type', 'queue_name', 'routing_key')def callback(body):
print("message body", body)consumer.run(callback)
IOLoop.instance().start()PubsubConsumer class
......................... code:: python
consumer = PubsubConsumer('project_id', 'path/to/sa.json', 'subscription_name', 'topic_name')
def callback(message):
print("message", message)try:
consumer.start_listening(callback)
except KeyboardInterrupt:
consumer.stop()Running tests with ``tox``
--------------------------Install ``tox``
::
$ pip install tox
Run tests
::
tox
.. _asynchronous_consumer_example: http://pika.readthedocs.io/en/0.13.1/examples/asynchronous_consumer_example.html