8000 GitHub - ermakov-oleg/asynqp-consumer: Consumer utility class for AMQP
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ermakov-oleg/asynqp-consumer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Consumer utility class for AMQP

Build Status

DEPRECATED: use aioamqp-consumer-best instead.

Installation

Requirements:

  • python >= 3.5
pip install asynqp-consumer

Example:

import asyncio
from typing import List

from asynqp_consumer import ConnectionParams, Consumer, Exchange, Message, Queue, QueueBinding


async def callback(messages: List[Message]) -> None:
    for message in messages:
        print(message.body)  # json
        message.ack()


exchange = Exchange('test_exchange')

test_queue = Queue(
    name='test_queue',
    bindings=[
        QueueBinding(
            exchange=exchange,
            routing_key='test_routing_key'
        ),
    ]
)

rabbitmq_connection_params = [  # Round robin
    ConnectionParams.from_string('amqp:////'),
    ConnectionParams(username='test', password='test')
]

consumer = Consumer(
    queue=test_queue,
    connection_params=rabbitmq_connection_params,
    callback=callback,
    prefetch_count=100,
    check_bulk_interval=0.3
)

try:
    asyncio.get_event_loop().run_until_complete(consumer.start())
finally:
    consumer.close()

About

Consumer utility class for AMQP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%
0