Skip to main content

py-queue-manager

Library to deal with RabbitMQ and Google PubSub

Usage

QueueManager class

>>> 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

from queue_manager.rabbitmq_consumer import RabbitMqPublisher

producer = RabbitMqPublisher('amqp://username:password@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

single_url = 'amqp://username:password@hostname:port'
# or multiple urls
multiple_urls = ('amqp://username:password@hostnameone:port', 'amqp://username:password@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

from tornado.ioloop import IOLoop
from queue_manager.tornado_consumer import TornadoConsumer

consumer = TornadoConsumer('amqp://username:password@hostname:port',
                           'exchange', 'exchange_type', 'queue_name', 'routing_key')


def callback(body):
    print("message body", body)

consumer.run(callback)
IOLoop.instance().start()

PubsubConsumer class

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

Metadata

Release files for PyQueueManager 1.12.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyQueueManager 1.12.1
File Size Uploaded Provenance
PyQueueManager-1.12.1.tar.gz 8.1 kB Without provenance Details

Release files / PyQueueManager-1.12.1.tar.gz

Download URL PyQueueManager-1.12.1.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4ebf4f39bafc76a2f8535e8acbb31db37b5a0679fc98abd48abb71fc3dec1cd5
BLAKE2b-256 checksum
How to use checksums
cc97e4da66cd665b37e2928ca4987bb0115490de1c16a37c88409a466bd8c078
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.8

Security for PyQueueManager 1.12.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.12.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page