Skip to main content

Library to create simple rabbitmq workers resilient to connection/channel shutdown and simple producers.

Project description

RabbitmqWorker - Python worker for Rabbitmq

RabbitmqWorker is a worker for rabbitmq which automatically reconnect to the broker if any disconnection occurs.

Why?

The main library used to manage asynchronous tasks in python is Celery. Celery has its own internal message pattern that must be respected for celery to be able to interpret the messages correctly. In our architecture, we use microservices with multiple language where their task client does not follow Celery's message principle.

The scope of this library is to make an simple library to manage every kind of message from rabbitmq.

Installation

RabbitmqWorker is avaiable from PyPI. You can install it with pip.

$ pip install rabbitmq_worker

Usage

Instanciate a RabbitmqWorker with the appropriate configuration to your needs and run it. E.g:

def process_message(channel, basic_deliver, properties, body):
    print(body)
    channel.basic_ack(basic_deliver.delivery_tag)

rabbitmq_worker = RabbitmqWorker(
    amqp_url="amqp://guest:guest@localhost:5672/%2F",
    queue_name="my_queue",
    callback=process_message
)
rabbitmq_worker.run()

RabbitmqWorker use pika under the hood so your amqp_url must be compliant with URLParameters(https://pika.readthedocs.io/en/stable/modules/parameters.html#urlparameters) object.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rabbitmq_worker-0.0.7.tar.gz (11.8 kB view hashes)

Uploaded Source

Built Distribution

rabbitmq_worker-0.0.7-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page