Skip to main content

High level interfaces for work with RabbitMQ.

Project description

PyPI version GitHub Build Coverage Status PyPI - Python Version

Stack:

Installation

pip install rabbitmq-clients

Usage

Run rabbitMQ on your computer.

Producer

import asyncio
import json

from rabbitmq_clients import RabbitProducer

if __name__ == "__main__":
    producer = RabbitProducer(
        host='localhost',
        login='test',
        password='test',
    )
    data = {"result": True}
    asyncio.run(
        producer.publish(
            json.dumps(data),
            queue_name='test_queue_name',
        )
    )

Consume multiply queues (recommended)

import asyncio

from rabbitmq_clients import RabbitConsumer, QueueDTO
from rabbitmq_clients.core.types import JSON


async def show_decoded_result(result: JSON):
    print(result)


async def show_encoded_result(result: JSON):
    print(result.body)


if __name__ == "__main__":
    consumer = RabbitConsumer(
        host='localhost',
        login='test',
        password='test',
    )
    first_queue = QueueDTO(
        name='decoded_result',
        callback=show_decoded_result,
    )
    second_queue = QueueDTO(
        name='encoded_result',
        callback=show_encoded_result,
        auto_decode=False,
    )
    consumer.add_queue(first_queue)
    consumer.add_queue(second_queue)

    try:
        asyncio.run(consumer.consume_all())
    except KeyboardInterrupt:
        pass

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_clients-0.1.20.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

rabbitmq_clients-0.1.20-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file rabbitmq_clients-0.1.20.tar.gz.

File metadata

  • Download URL: rabbitmq_clients-0.1.20.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.5.0-1024-azure

File hashes

Hashes for rabbitmq_clients-0.1.20.tar.gz
Algorithm Hash digest
SHA256 02cf90abae7dee090e6bf9a2c81a0afa8a79083dfefcb09d0aeb9c59165a3f86
MD5 5aafe8b6fdf55815c18986f82921a860
BLAKE2b-256 cd06b5e36f2d9d4bea4af7ab950e7e6e7b010ab1323618732dc12e9dd1ea59a5

See more details on using hashes here.

File details

Details for the file rabbitmq_clients-0.1.20-py3-none-any.whl.

File metadata

  • Download URL: rabbitmq_clients-0.1.20-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.5.0-1024-azure

File hashes

Hashes for rabbitmq_clients-0.1.20-py3-none-any.whl
Algorithm Hash digest
SHA256 0e2f1fe5b91d15fda71344194d13a8e49258ace108eb829677f856fc600fc6f7
MD5 df879f55328f2fae83f8b373c32fc554
BLAKE2b-256 80e4ecc5d66a41175e540a55ca9fb9d1488211c95dcae373a3c0c5838c985285

See more details on using hashes here.

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