{"id":13594964,"url":"https://github.com/mosquito/aiormq","last_synced_at":"2026-02-22T23:10:51.926Z","repository":{"id":33845857,"uuid":"162988073","full_name":"mosquito/aiormq","owner":"mosquito","description":"Pure python AMQP 0.9.1 asynchronous client library","archived":false,"fork":false,"pushed_at":"2025-10-21T11:55:50.000Z","size":690,"stargazers_count":313,"open_issues_count":38,"forks_count":64,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-11-10T04:34:21.776Z","etag":null,"topics":["aiormq","amqp","amqp0-9-1","async","async-await","asynchronous","asyncio","rabbitmq","rabbitmq-client","rabbitmq-python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mosquito.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-12-24T12:22:12.000Z","updated_at":"2025-10-23T21:18:31.000Z","dependencies_parsed_at":"2026-02-22T23:04:13.121Z","dependency_job_id":null,"html_url":"https://github.com/mosquito/aiormq","commit_stats":{"total_commits":407,"total_committers":31,"mean_commits":"13.129032258064516","dds":"0.10810810810810811","last_synced_commit":"5b9c88dff8c23b7c7a61dd5fd3e0490e82609a7e"},"previous_names":[],"tags_count":111,"template":false,"template_full_name":null,"purl":"pkg:github/mosquito/aiormq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosquito%2Faiormq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosquito%2Faiormq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosquito%2Faiormq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosquito%2Faiormq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mosquito","download_url":"https://codeload.github.com/mosquito/aiormq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosquito%2Faiormq/sbom","scorecard":{"id":660954,"data":{"date":"2025-08-11","repo":{"name":"github.com/mosquito/aiormq","commit":"a069a8d90c77763ac37ae64d667a80bb52f9216b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.5,"checks":[{"name":"Code-Review","score":5,"reason":"Found 5/9 approved changesets -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":10,"reason":"12 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/tests.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: COPYING:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/tests.yml:133: update your workflow using https://app.stepsecurity.io/secureworkflow/mosquito/aiormq/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/mosquito/aiormq/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/mosquito/aiormq/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/mosquito/aiormq/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/mosquito/aiormq/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/mosquito/aiormq/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/mosquito/aiormq/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:59: update your workflow using https://app.stepsecurity.io/secureworkflow/mosquito/aiormq/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:61: update your workflow using https://app.stepsecurity.io/secureworkflow/mosquito/aiormq/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:66: update your workflow using https://app.stepsecurity.io/secureworkflow/mosquito/aiormq/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:97: update your workflow using https://app.stepsecurity.io/secureworkflow/mosquito/aiormq/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:99: update your workflow using https://app.stepsecurity.io/secureworkflow/mosquito/aiormq/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:104: update your workflow using https://app.stepsecurity.io/secureworkflow/mosquito/aiormq/tests.yml/master?enable=pin","Warn: containerImage not pinned by hash: tests/certs/Dockerfile:1: pin your Docker image by updating rabbitmq:3.8-management-alpine to rabbitmq:3.8-management-alpine@sha256:c3e526769bfd885c898d1132e1008b216800e8543619c30d5959b220285564ef","Warn: pipCommand not pinned by hash: .github/workflows/tests.yml:109","Warn: pipCommand not pinned by hash: .github/workflows/tests.yml:27","Warn: pipCommand not pinned by hash: .github/workflows/tests.yml:46","Warn: pipCommand not pinned by hash: .github/workflows/tests.yml:71","Info:   0 out of  12 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   1 containerImage dependencies pinned","Info:   0 out of   4 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":7,"reason":"3 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2022-42969","Warn: Project is vulnerable to: PYSEC-2025-49 / GHSA-5rjg-fvgr-3xxf","Warn: Project is vulnerable to: GHSA-cx63-2mw6-8hw5"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T16:11:16.494Z","repository_id":33845857,"created_at":"2025-08-21T16:11:16.494Z","updated_at":"2025-08-21T16:11:16.494Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29730365,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T20:09:16.275Z","status":"ssl_error","status_checked_at":"2026-02-22T20:09:13.750Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aiormq","amqp","amqp0-9-1","async","async-await","asynchronous","asyncio","rabbitmq","rabbitmq-client","rabbitmq-python"],"created_at":"2024-08-01T16:01:41.624Z","updated_at":"2026-02-22T23:10:51.917Z","avatar_url":"https://github.com/mosquito.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"======\nAIORMQ\n======\n\n.. image:: https://coveralls.io/repos/github/mosquito/aiormq/badge.svg?branch=master\n   :target: https://coveralls.io/github/mosquito/aiormq?branch=master\n   :alt: Coveralls\n\n.. image:: https://img.shields.io/pypi/status/aiormq.svg\n   :target: https://github.com/mosquito/aiormq\n   :alt: Status\n\n.. image:: https://github.com/mosquito/aiormq/workflows/tests/badge.svg\n   :target: https://github.com/mosquito/aiormq/actions?query=workflow%3Atests\n   :alt: Build status\n\n.. image:: https://img.shields.io/pypi/v/aiormq.svg\n   :target: https://pypi.python.org/pypi/aiormq/\n   :alt: Latest Version\n\n.. image:: https://img.shields.io/pypi/wheel/aiormq.svg\n   :target: https://pypi.python.org/pypi/aiormq/\n\n.. image:: https://img.shields.io/pypi/pyversions/aiormq.svg\n   :target: https://pypi.python.org/pypi/aiormq/\n\n.. image:: https://img.shields.io/pypi/l/aiormq.svg\n   :target: https://github.com/mosquito/aiormq/blob/master/LICENSE.md\n\n\naiormq is a pure python AMQP client library.\n\n.. contents:: Table of contents\n\nStatus\n======\n\n* 3.x.x branch - Production/Stable\n* 4.x.x branch - Unstable (Experimental)\n* 5.x.x and greater is only Production/Stable releases.\n\nFeatures\n========\n\n* Connecting by URL\n\n * amqp example: **amqp://user:password@server.host/vhost**\n * secure amqp example: **amqps://user:password@server.host/vhost?cafile=ca.pem\u0026keyfile=key.pem\u0026certfile=cert.pem\u0026no_verify_ssl=0**\n\n* Buffered queue for received frames\n* Only `PLAIN`_ auth mechanism support\n* `Publisher confirms`_ support\n* `Transactions`_ support\n* Channel based asynchronous locks\n\n  .. note::\n      AMQP 0.9.1 requires serialize sending for some frame types\n      on the channel. e.g. Content body must be following after\n      content header. But frames might be sent asynchronously\n      on another channels.\n\n* Tracking unroutable messages\n  (Use **connection.channel(on_return_raises=False)** for disabling)\n* Full SSL/TLS support, using your choice of:\n    * ``amqps://`` url query parameters:\n        * ``cafile=`` - string contains path to ca certificate file\n        * ``capath=`` - string contains path to ca certificates\n        * ``cadata=`` - base64 encoded ca certificate data\n        * ``keyfile=`` - string contains path to key file\n        * ``certfile=`` - string contains path to certificate file\n        * ``no_verify_ssl`` - boolean disables certificates validation\n    * ``context=`` `SSLContext`_ keyword argument to ``connect()``.\n* Python `type hints`_\n* Uses `pamqp`_ as an AMQP 0.9.1 frame encoder/decoder\n\n\n.. _Publisher confirms: https://www.rabbitmq.com/confirms.html\n.. _Transactions: https://www.rabbitmq.com/semantics.html\n.. _PLAIN: https://www.rabbitmq.com/authentication.html\n.. _type hints: https://docs.python.org/3/library/typing.html\n.. _pamqp: https://pypi.org/project/pamqp/\n.. _SSLContext: https://docs.python.org/3/library/ssl.html#ssl.SSLContext\n\nTutorial\n========\n\nIntroduction\n------------\n\nSimple consumer\n***************\n\n.. code-block:: python\n\n    import asyncio\n    import aiormq\n\n    async def on_message(message):\n        \"\"\"\n        on_message doesn't necessarily have to be defined as async.\n        Here it is to show that it's possible.\n        \"\"\"\n        print(f\" [x] Received message {message!r}\")\n        print(f\"Message body is: {message.body!r}\")\n        print(\"Before sleep!\")\n        await asyncio.sleep(5)   # Represents async I/O operations\n        print(\"After sleep!\")\n\n\n    async def main():\n        # Perform connection\n        connection = await aiormq.connect(\"amqp://guest:guest@localhost/\")\n\n        # Creating a channel\n        channel = await connection.channel()\n\n        # Declaring queue\n        declare_ok = await channel.queue_declare('hello', auto_delete=True)\n        consume_ok = await channel.basic_consume(\n            declare_ok.queue, on_message, no_ack=True\n        )\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(main())\n    loop.run_forever()\n\n\nSimple publisher\n****************\n\n.. code-block:: python\n    :name: test_simple_publisher\n\n    import asyncio\n    from typing import Optional\n\n    import aiormq\n    from aiormq.abc import DeliveredMessage\n\n\n    MESSAGE: Optional[DeliveredMessage] = None\n\n\n    async def main():\n        global MESSAGE\n\n        body = b'Hello World!'\n\n        # Perform connection\n        connection = await aiormq.connect(\"amqp://guest:guest@localhost//\")\n\n        # Creating a channel\n        channel = await connection.channel()\n\n        declare_ok = await channel.queue_declare(\"hello\", auto_delete=True)\n\n        # Sending the message\n        await channel.basic_publish(body, routing_key='hello')\n        print(f\" [x] Sent {body}\")\n\n        MESSAGE = await channel.basic_get(declare_ok.queue)\n        print(f\" [x] Received message from {declare_ok.queue!r}\")\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(main())\n\n    assert MESSAGE is not None\n    assert MESSAGE.routing_key == \"hello\"\n    assert MESSAGE.body == b'Hello World!'\n\n\nWork Queues\n-----------\n\nCreate new task\n***************\n\n.. code-block:: python\n\n    import sys\n    import asyncio\n    import aiormq\n\n\n    async def main():\n        # Perform connection\n        connection = await aiormq.connect(\"amqp://guest:guest@localhost/\")\n\n        # Creating a channel\n        channel = await connection.channel()\n\n        body = b' '.join(sys.argv[1:]) or b\"Hello World!\"\n\n        # Sending the message\n        await channel.basic_publish(\n            body,\n            routing_key='task_queue',\n            properties=aiormq.spec.Basic.Properties(\n                delivery_mode=1,\n            )\n        )\n\n        print(f\" [x] Sent {body!r}\")\n\n        await connection.close()\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(main())\n\n\nSimple worker\n*************\n\n.. code-block:: python\n\n    import asyncio\n    import aiormq\n    import aiormq.abc\n\n\n    async def on_message(message: aiormq.abc.DeliveredMessage):\n        print(f\" [x] Received message {message!r}\")\n        print(f\"     Message body is: {message.body!r}\")\n\n\n    async def main():\n        # Perform connection\n        connection = await aiormq.connect(\"amqp://guest:guest@localhost/\")\n\n\n        # Creating a channel\n        channel = await connection.channel()\n        await channel.basic_qos(prefetch_count=1)\n\n        # Declaring queue\n        declare_ok = await channel.queue_declare('task_queue', durable=True)\n\n        # Start listening the queue with name 'task_queue'\n        await channel.basic_consume(declare_ok.queue, on_message, no_ack=True)\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(main())\n\n    # we enter a never-ending loop that waits for data and runs\n    # callbacks whenever necessary.\n    print(\" [*] Waiting for messages. To exit press CTRL+C\")\n    loop.run_forever()\n\n\nPublish Subscribe\n-----------------\n\nPublisher\n*********\n\n.. code-block:: python\n\n    import sys\n    import asyncio\n    import aiormq\n\n\n    async def main():\n        # Perform connection\n        connection = await aiormq.connect(\"amqp://guest:guest@localhost/\")\n\n        # Creating a channel\n        channel = await connection.channel()\n\n        await channel.exchange_declare(\n            exchange='logs', exchange_type='fanout'\n        )\n\n        body = b' '.join(sys.argv[1:]) or b\"Hello World!\"\n\n        # Sending the message\n        await channel.basic_publish(\n            body, routing_key='info', exchange='logs'\n        )\n\n        print(f\" [x] Sent {body!r}\")\n\n        await connection.close()\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(main())\n\n\nSubscriber\n**********\n\n.. code-block:: python\n\n    import asyncio\n    import aiormq\n    import aiormq.abc\n\n\n    async def on_message(message: aiormq.abc.DeliveredMessage):\n        print(f\"[x] {message.body!r}\")\n\n        await message.channel.basic_ack(\n            message.delivery.delivery_tag\n        )\n\n\n    async def main():\n        # Perform connection\n        connection = await aiormq.connect(\"amqp://guest:guest@localhost/\")\n\n        # Creating a channel\n        channel = await connection.channel()\n        await channel.basic_qos(prefetch_count=1)\n\n        await channel.exchange_declare(\n            exchange='logs', exchange_type='fanout'\n        )\n\n        # Declaring queue\n        declare_ok = await channel.queue_declare(exclusive=True)\n\n        # Binding the queue to the exchange\n        await channel.queue_bind(declare_ok.queue, 'logs')\n\n        # Start listening the queue with name 'task_queue'\n        await channel.basic_consume(declare_ok.queue, on_message)\n\n\n    loop = asyncio.get_event_loop()\n    loop.create_task(main())\n\n    # we enter a never-ending loop that waits for data\n    # and runs callbacks whenever necessary.\n    print(' [*] Waiting for logs. To exit press CTRL+C')\n    loop.run_forever()\n\n\nRouting\n-------\n\nDirect consumer\n***************\n\n.. code-block:: python\n\n    import sys\n    import asyncio\n    import aiormq\n    import aiormq.abc\n\n\n    async def on_message(message: aiormq.abc.DeliveredMessage):\n        print(f\" [x] {message.delivery.routing_key!r}:{message.body!r}\"\n        await message.channel.basic_ack(\n            message.delivery.delivery_tag\n        )\n\n\n    async def main():\n        # Perform connection\n        connection = aiormq.Connection(\"amqp://guest:guest@localhost/\")\n        await connection.connect()\n\n        # Creating a channel\n        channel = await connection.channel()\n        await channel.basic_qos(prefetch_count=1)\n\n        severities = sys.argv[1:]\n\n        if not severities:\n            sys.stderr.write(f\"Usage: {sys.argv[0]} [info] [warning] [error]\\n\")\n            sys.exit(1)\n\n        # Declare an exchange\n        await channel.exchange_declare(\n            exchange='logs', exchange_type='direct'\n        )\n\n        # Declaring random queue\n        declare_ok = await channel.queue_declare(durable=True, auto_delete=True)\n\n        for severity in severities:\n            await channel.queue_bind(\n                declare_ok.queue, 'logs', routing_key=severity\n            )\n\n        # Start listening the random queue\n        await channel.basic_consume(declare_ok.queue, on_message)\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(main())\n\n    # we enter a never-ending loop that waits for data\n    # and runs callbacks whenever necessary.\n    print(\" [*] Waiting for messages. To exit press CTRL+C\")\n    loop.run_forever()\n\n\nEmitter\n*******\n\n.. code-block:: python\n\n    import sys\n    import asyncio\n    import aiormq\n\n\n    async def main():\n        # Perform connection\n        connection = await aiormq.connect(\"amqp://guest:guest@localhost/\")\n\n        # Creating a channel\n        channel = await connection.channel()\n\n        await channel.exchange_declare(\n            exchange='logs', exchange_type='direct'\n        )\n\n        body = (\n            b' '.join(arg.encode() for arg in sys.argv[2:])\n            or\n            b\"Hello World!\"\n        )\n\n        # Sending the message\n        routing_key = sys.argv[1] if len(sys.argv) \u003e 2 else 'info'\n\n        await channel.basic_publish(\n            body, exchange='logs', routing_key=routing_key,\n            properties=aiormq.spec.Basic.Properties(\n                delivery_mode=1\n            )\n        )\n\n        print(f\" [x] Sent {body!r}\")\n\n        await connection.close()\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(main())\n\nTopics\n------\n\nPublisher\n*********\n\n.. code-block:: python\n\n    import sys\n    import asyncio\n    import aiormq\n\n\n    async def main():\n        # Perform connection\n        connection = await aiormq.connect(\"amqp://guest:guest@localhost/\")\n\n        # Creating a channel\n        channel = await connection.channel()\n\n        await channel.exchange_declare('topic_logs', exchange_type='topic')\n\n        routing_key = (\n            sys.argv[1] if len(sys.argv) \u003e 2 else 'anonymous.info'\n        )\n\n        body = (\n            b' '.join(arg.encode() for arg in sys.argv[2:])\n            or\n            b\"Hello World!\"\n        )\n\n        # Sending the message\n        await channel.basic_publish(\n            body, exchange='topic_logs', routing_key=routing_key,\n            properties=aiormq.spec.Basic.Properties(\n                delivery_mode=1\n            )\n        )\n\n        print(f\" [x] Sent {body!r}\")\n\n        await connection.close()\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(main())\n\nConsumer\n********\n\n.. code-block:: python\n\n    import asyncio\n    import sys\n    import aiormq\n    import aiormq.abc\n\n\n    async def on_message(message: aiormq.abc.DeliveredMessage):\n        print(f\" [x] {message.delivery.routing_key!r}:{message.body!r}\")\n        await message.channel.basic_ack(\n            message.delivery.delivery_tag\n        )\n\n\n    async def main():\n        # Perform connection\n        connection = await aiormq.connect(\n            \"amqp://guest:guest@localhost/\", loop=loop\n        )\n\n        # Creating a channel\n        channel = await connection.channel()\n        await channel.basic_qos(prefetch_count=1)\n\n        # Declare an exchange\n        await channel.exchange_declare('topic_logs', exchange_type='topic')\n\n        # Declaring queue\n        declare_ok = await channel.queue_declare('task_queue', durable=True)\n\n        binding_keys = sys.argv[1:]\n\n        if not binding_keys:\n            sys.stderr.write(\n                f\"Usage: {sys.argv[0]} [binding_key]...\\n\"\n            )\n            sys.exit(1)\n\n        for binding_key in binding_keys:\n            await channel.queue_bind(\n                declare_ok.queue, 'topic_logs', routing_key=binding_key\n            )\n\n        # Start listening the queue with name 'task_queue'\n        await channel.basic_consume(declare_ok.queue, on_message)\n\n\n    loop = asyncio.get_event_loop()\n    loop.create_task(main())\n\n    # we enter a never-ending loop that waits for\n    # data and runs callbacks whenever necessary.\n    print(\" [*] Waiting for messages. To exit press CTRL+C\")\n    loop.run_forever()\n\nRemote procedure call (RPC)\n---------------------------\n\nRPC server\n**********\n\n.. code-block:: python\n\n    import asyncio\n    import aiormq\n    import aiormq.abc\n\n\n    def fib(n):\n        if n == 0:\n            return 0\n        elif n == 1:\n            return 1\n        else:\n            return fib(n-1) + fib(n-2)\n\n\n    async def on_message(message:aiormq.abc.DeliveredMessage):\n        n = int(message.body.decode())\n\n        print(f\" [.] fib({n})\")\n        response = str(fib(n)).encode()\n\n        await message.channel.basic_publish(\n            response, routing_key=message.header.properties.reply_to,\n            properties=aiormq.spec.Basic.Properties(\n                correlation_id=message.header.properties.correlation_id\n            ),\n\n        )\n\n        await message.channel.basic_ack(message.delivery.delivery_tag)\n        print('Request complete')\n\n\n    async def main():\n        # Perform connection\n        connection = await aiormq.connect(\"amqp://guest:guest@localhost/\")\n\n        # Creating a channel\n        channel = await connection.channel()\n\n        # Declaring queue\n        declare_ok = await channel.queue_declare('rpc_queue')\n\n        # Start listening the queue with name 'hello'\n        await channel.basic_consume(declare_ok.queue, on_message)\n\n\n    loop = asyncio.get_event_loop()\n    loop.create_task(main())\n\n    # we enter a never-ending loop that waits for data\n    # and runs callbacks whenever necessary.\n    print(\" [x] Awaiting RPC requests\")\n    loop.run_forever()\n\n\nRPC client\n**********\n\n.. code-block:: python\n\n    import asyncio\n    import uuid\n    import aiormq\n    import aiormq.abc\n\n\n    class FibonacciRpcClient:\n        def __init__(self):\n            self.connection = None      # type: aiormq.Connection\n            self.channel = None         # type: aiormq.Channel\n            self.callback_queue = ''\n            self.futures = {}\n            self.loop = loop\n\n        async def connect(self):\n            self.connection = await aiormq.connect(\"amqp://guest:guest@localhost/\")\n\n            self.channel = await self.connection.channel()\n            declare_ok = await self.channel.queue_declare(\n                exclusive=True, auto_delete=True\n            )\n\n            await self.channel.basic_consume(declare_ok.queue, self.on_response)\n\n            self.callback_queue = declare_ok.queue\n\n            return self\n\n        async def on_response(self, message: aiormq.abc.DeliveredMessage):\n            future = self.futures.pop(message.header.properties.correlation_id)\n            future.set_result(message.body)\n\n        async def call(self, n):\n            correlation_id = str(uuid.uuid4())\n            future = loop.create_future()\n\n            self.futures[correlation_id] = future\n\n            await self.channel.basic_publish(\n                str(n).encode(), routing_key='rpc_queue',\n                properties=aiormq.spec.Basic.Properties(\n                    content_type='text/plain',\n                    correlation_id=correlation_id,\n                    reply_to=self.callback_queue,\n                )\n            )\n\n            return int(await future)\n\n\n    async def main():\n        fibonacci_rpc = await FibonacciRpcClient().connect()\n        print(\" [x] Requesting fib(30)\")\n        response = await fibonacci_rpc.call(30)\n        print(r\" [.] Got {response!r}\")\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(main())\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmosquito%2Faiormq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmosquito%2Faiormq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmosquito%2Faiormq/lists"}