Skip to main content

High level interfaces for work with RabbitMQ.

Project description

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',
        queue_name='test_queue',
        exchange_name='',
        routing_key='',
    )
    data = {"result": True}
    asyncio.run(producer.publish(json.dumps(data)))

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',
        queue_name='decoded_result',
    )
    first_queue = QueueDTO(
        name='test_queue',
        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.12.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rabbitmq_clients-0.1.12-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for rabbitmq_clients-0.1.12.tar.gz
Algorithm Hash digest
SHA256 e44afd520471fa273774466e3ea8984a35b0d8183c193c6fea2a25968c252627
MD5 ef982c8cf7184baa8bd204cf2c37d355
BLAKE2b-256 247b56f801acb460c4d1f31f141912047612ebceb2a959518f0a778524180bd3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for rabbitmq_clients-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 d5e1ebc72475b0bf8f4dd8d7f2e75ce82a06c9f7c4d7990fcf38a55cf5e70695
MD5 e535ab9df95517db56ce0deb15824044
BLAKE2b-256 3532328911a2b31031031d2560672bc2d5e655f377b9ee2a9ee0f66d20d2334e

See more details on using hashes here.

Supported by

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