Skip to main content

No project description provided

Project description

AMQP Client Python

License Package version Supported Python versions Downloads Vulnerabilities Releases


Client with high level of abstraction for manipulation of messages in the event bus RabbitMQ.

Features:

  • Automatic creation and management of queues, exchanges and channels;
  • Support for direct, topic and fanout exchanges;
  • Publish;
  • Subscribe;
  • Support for a Remote procedure call (RPC).

Examples:

  • basic usage
    # basic configuration
    from amqp_client_python import (
        AsyncEventbusRabbitMQ,
        Config, Options
    )
    from amqp_client_python.event import IntegrationEvent, IntegrationEventHandler
    config = Config(Options("queue", "rpc_queue", "rpc_exchange"))
    eventbus = AsyncEventbusRabbitMQ(config)
    # publish
    class ExampleEvent(IntegrationEvent):
        EVENT_NAME: str = "ExampleEvent"
        def __init__(self, event_type: str, message = []) -> None:
            super().__init__(self.EVENT_NAME, event_type)
            self.message = message
    
    publish_event = ExampleEvent(rpc_exchange, ["message"])
    eventbus.publish(publish_event, rpc_routing_key, "direct")
    # subscribe
    class ExampleEventHandler(IntegrationEventHandler):
        def handle(self, body) -> None:
            print(body) # handle messages
    await eventbus.subscribe(subscribe_event, subscribe_event_handle, rpc_routing_key)
    # rpc_publish
    response = await eventbus.rpc_client(rpc_exchange, "user.find", ["content_message"])
    # provider
    async def handle2(*body) -> bytes:
        print(f"body: {body}")
        return b"content"
    await eventbus.provide_resource("user.find", handle)
    

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

amqp_client_python-0.1.4.tar.gz (19.8 kB view hashes)

Uploaded Source

Built Distributions

amqp_client_python-0.1.4-py3-none-any.whl (27.4 kB view hashes)

Uploaded Python 3

amqp_client_python-0.1.4-1-py3-none-any.whl (27.9 kB view hashes)

Uploaded Python 3

Supported by

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