Metadata-Version: 2.3
Name: rabbitmq-clients
Version: 0.1.21
Summary: High level interfaces for work with RabbitMQ.
License: MIT
Author: deskent
Author-email: battenetciz@gmail.com
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: aio-pika (>=9.4.1,<10.0.0)
Project-URL: Repository, https://github.com/Deskent/rabbit_mq_client
Description-Content-Type: text/markdown

[![PyPI version](https://badge.fury.io/py/rabbitmq-clients.svg)](https://pypi.org/project/rabbitmq-clients/)
[![GitHub Build](https://github.com/Deskent/rabbit_mq_client/workflows/Tests/badge.svg)](https://github.com/Deskent/rabbit_mq_client/actions)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/rabbitmq-clients.svg)](https://pypi.org/project/rabbitmq-clients/)


### Stack:

- [x] <a href="https://www.python.org/"><img src="https://raw.githubusercontent.com/devicons/devicon/master/icons/python/python-plain.svg" alt="python" width="15" height="15"/>
  Python 3.10+ <br/></a>
- [x] <a href="https://github.com/mosquito/aio-pika"><img src="https://raw.githubusercontent.com/mosquito/aio-pika/b61062893c4973dbbd5ac6a6afa55e4e74b28ae5/logo.svg" alt="aio-pika" width="15" height="15"/>
  aio-pika 9.4.1+ <br/></a>


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

