All Projects → aio-libs → aioamqp_consumer

aio-libs / aioamqp_consumer

Licence: MIT license
consumer/producer/rpc library built over aioamqp

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to aioamqp consumer

aiorabbit
An AsyncIO RabbitMQ client for Python 3
Stars: ✭ 18 (-50%)
Mutual labels:  rabbitmq, asyncio
celery-kubernetes-example
Small Flask app with scalable, asynchronous backend workers deployed on Kubernetes.
Stars: ✭ 79 (+119.44%)
Mutual labels:  rabbitmq, producer-consumer
Aio Pika
AMQP 0.9 client designed for asyncio and humans.
Stars: ✭ 611 (+1597.22%)
Mutual labels:  rabbitmq, asyncio
tomodachi
💻 Microservice library / framework using Python's asyncio event loop with full support for HTTP + WebSockets, AWS SNS+SQS, RabbitMQ / AMQP, middleware, etc. Extendable for GraphQL, protobuf, gRPC, among other technologies.
Stars: ✭ 170 (+372.22%)
Mutual labels:  rabbitmq, asyncio
Aiormq
Pure python AMQP 0.9.1 asynchronous client library
Stars: ✭ 112 (+211.11%)
Mutual labels:  rabbitmq, asyncio
waspy
WASP framework for Python
Stars: ✭ 43 (+19.44%)
Mutual labels:  rabbitmq, asyncio
pd-tech-fest-2019
Demo code for PD Tech Fest 2019 showcasing event driven autoscaling using KEDA
Stars: ✭ 21 (-41.67%)
Mutual labels:  rabbitmq
Cloud-Native-App-Spring-Boot
A Cloud Native App with Spring Coud Security with KeyCloak Auth Server, API Gateway Server, Naming Server, Config Server and Distributed Tracing and ELK Stack hosted in K8s
Stars: ✭ 19 (-47.22%)
Mutual labels:  rabbitmq
rabbitmq-auth-backend-oauth2-spike
See rabbitmq/rabbitmq-auth-backend-oauth2 instead.
Stars: ✭ 17 (-52.78%)
Mutual labels:  rabbitmq
stream video server
demonstrates how to create video streaming server with the help of aiohttp and opencv
Stars: ✭ 15 (-58.33%)
Mutual labels:  asyncio
Sample-ConsoleService
A sample .NET Core 2.2 Console Service
Stars: ✭ 33 (-8.33%)
Mutual labels:  rabbitmq
scrapy-distributed
A series of distributed components for Scrapy. Including RabbitMQ-based components, Kafka-based components, and RedisBloom-based components for Scrapy.
Stars: ✭ 38 (+5.56%)
Mutual labels:  rabbitmq
pyladies-courseware
Homework/task submit and review web app · based on React and Python aiohttp
Stars: ✭ 14 (-61.11%)
Mutual labels:  asyncio
aiohttp-mako
mako template renderer for aiohttp.web
Stars: ✭ 32 (-11.11%)
Mutual labels:  asyncio
spring-boot-examples
本仓库为《Spring Boot 系列文章》代码仓库,欢迎点赞、收藏。
Stars: ✭ 52 (+44.44%)
Mutual labels:  rabbitmq
rabbit
Build Elixir applications with RabbitMQ
Stars: ✭ 36 (+0%)
Mutual labels:  rabbitmq
AsyncIO
.NET library for handling asynchronous file system operations
Stars: ✭ 20 (-44.44%)
Mutual labels:  asyncio
postmodel
ORM library for Python 3.6+, asyncio. Provides Django ORM like API.
Stars: ✭ 15 (-58.33%)
Mutual labels:  asyncio
rabbitmq-auth-backend-cache
Authorisation result caching plugin (backend) for RabbitMQ
Stars: ✭ 17 (-52.78%)
Mutual labels:  rabbitmq
watermill-amqp
AMQP Pub/Sub for the Watermill project.
Stars: ✭ 27 (-25%)
Mutual labels:  rabbitmq

aioamqp_consumer

info:consumer/producer/rpc library built over aioamqp

Installation

pip install aioamqp_consumer

Consumer/Producer usage

import asyncio

from aioamqp_consumer import Consumer, Producer


async def task(payload, properties):
    await asyncio.sleep(1)
    print(payload)


async def main():
    amqp_url = 'amqp://guest:[email protected]:5672//'
    amqp_queue = 'your-queue-here'
    queue_kwargs = {
        'durable': True,
    }
    # https://aioamqp.readthedocs.io/en/latest/api.html#aioamqp.connect
    amqp_kwargs = {}

    async with Producer(amqp_url, amqp_kwargs=amqp_kwargs) as producer:
        for _ in range(5):
            await producer.publish(
                b'hello',
                amqp_queue,
                queue_kwargs=queue_kwargs,
            )

    consumer = Consumer(
        amqp_url,
        task,
        amqp_queue,
        queue_kwargs=queue_kwargs,
        amqp_kwargs=amqp_kwargs,
    )
    await consumer.scale(20)  # scale up to 20 background coroutines
    await consumer.scale(5)  # downscale to 5 background coroutines
    # wait for rabbitmq queue is empty and all local messages are processed
    await consumer.join()
    consumer.close()
    await consumer.wait_closed()


loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()

RPC usage

import asyncio

from aioamqp_consumer import RpcClient, RpcServer, rpc

payload = b'test'


@rpc(queue_name='random_queue')
async def method(payload):
    print(payload)
    return payload


async def main():
    amqp_url = 'amqp://guest:[email protected]:5672//'

    server = RpcServer(amqp_url, method=method)

    client = RpcClient(amqp_url)

    ret = await client.wait(method(payload))

    assert ret == payload

    await client.close()

    await server.stop()


loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()

For built-in json encoding/decoding, take a look on aioamqp_consumer.json_rpc

For production deploying aioamqp_consumer.Consumer/aioamqp_consumer.RpcServer there is built-in simpler runner:

from aioamqp_consumer import RpcServer, json_rpc

amqp_url = 'amqp://guest:[email protected]:5672//'


@json_rpc(queue_name='random_queue')
async def square(*, x):
    ret = x ** 2

    print(x, ret)

    return ret

if __name__ == '__main__':
    RpcServer(amqp_url, method=square).run()

Thanks

The library was donated by Ocean S.A.

Thanks to the company for contribution.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].