Skip to main content

High level interfaces for work with RabbitMQ.

Project description

PyPI version GitHub Build 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.21.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.21-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rabbitmq_clients-0.1.21.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.11 Linux/6.8.0-1017-azure

File hashes

Hashes for rabbitmq_clients-0.1.21.tar.gz
Algorithm Hash digest
SHA256 b34cbcbe2bf20b84cbb7ce23b4568dacc0e7092f057bbf5b5eda024a39e24313
MD5 55cdc478925d566ba6d2914b4945ea2b
BLAKE2b-256 84db766b48436a9da5423c447fadb2b80a6e7ed53ab8493cdfb38c680a6d8e6b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rabbitmq_clients-0.1.21-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.11 Linux/6.8.0-1017-azure

File hashes

Hashes for rabbitmq_clients-0.1.21-py3-none-any.whl
Algorithm Hash digest
SHA256 ae5bd709a6f1f652e19f94ad2e1da2b86e90d8b7eb2043e7c4c0ec259127bf98
MD5 a140f214c1b606b5d15b1ea01e035060
BLAKE2b-256 47cca411d7e390f099a75fd49c1c029f282daef85325ec3ee08cf936e0cc5d97

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