{"id":1897,"library":"aiormq","title":"aiormq: Asynchronous AMQP Client","description":"aiormq is a pure Python asynchronous client library for the AMQP 0.9.1 protocol, commonly used for interacting with RabbitMQ. It provides a non-blocking interface leveraging `asyncio`. The current version is 6.9.4, and it maintains a steady release cadence with frequent patch and minor updates addressing bug fixes and performance improvements.","status":"active","version":"6.9.4","language":"python","source_language":"en","source_url":"https://github.com/mosquito/aiormq","tags":["AMQP","RabbitMQ","asyncio","message queue","messaging"],"install":[{"cmd":"pip install aiormq","lang":"bash","label":"Install aiormq"}],"dependencies":[{"reason":"Core dependency for AMQP 0.9.1 protocol framing.","package":"pamqp","optional":false}],"imports":[{"symbol":"connect","correct":"from aiormq import connect"},{"note":"While Channel is part of the internal structure, for type hinting, import from `aiormq.abc`.","symbol":"Channel","correct":"from aiormq.abc import Channel"},{"note":"Required for type hinting message callbacks during consumption.","symbol":"IncomingMessage","correct":"from aiormq.abc import IncomingMessage"}],"quickstart":{"code":"import asyncio\nimport os\nfrom aiormq import connect\nfrom aiormq.abc import IncomingMessage\n\n# Get AMQP URL from environment variable, default to local RabbitMQ\nAMQP_URL = os.environ.get('AMQP_URL', 'amqp://guest:guest@localhost/')\nQUEUE_NAME = 'aiormq_test_queue'\n\nasync def on_message(message: IncomingMessage):\n    \"\"\"Callback for consuming messages.\"\"\"\n    print(f\"[x] Received: {message.body.decode()}\")\n    await message.ack() # Acknowledge the message\n\nasync def main():\n    connection = None\n    try:\n        # Establish connection\n        print(f\"[*] Connecting to {AMQP_URL}...\")\n        connection = await connect(AMQP_URL)\n        print(\"[*] Connection established.\")\n\n        # Create a channel\n        channel = await connection.channel()\n        print(\"[*] Channel created.\")\n\n        # Declare a queue (idempotent operation)\n        await channel.queue_declare(QUEUE_NAME)\n        print(f\"[*] Queue '{QUEUE_NAME}' declared.\")\n\n        # Publish a message\n        message_body = b\"Hello, aiormq world!\"\n        await channel.basic_publish(\n            exchange='',\n            routing_key=QUEUE_NAME,\n            body=message_body\n        )\n        print(f\"[x] Published message: '{message_body.decode()}'\")\n\n        # Start consuming messages\n        consumer_tag = await channel.basic_consume(QUEUE_NAME, on_message)\n        print(f\"[*] Consuming from '{QUEUE_NAME}'. Consumer tag: {consumer_tag}\")\n\n        # Keep the consumer running for a short period (e.g., 5 seconds)\n        print(\"[*] Waiting for messages... Press Ctrl+C to exit\")\n        await asyncio.sleep(5)\n\n        # Stop consuming\n        await channel.basic_cancel(consumer_tag)\n        print(f\"[*] Consumer '{consumer_tag}' cancelled.\")\n\n    except Exception as e:\n        print(f\"[!] An error occurred: {e}\")\n    finally:\n        if connection:\n            print(\"[*] Closing connection...\")\n            await connection.close()\n            print(\"[*] Connection closed.\")\n\nif __name__ == '__main__':\n    asyncio.run(main())\n","lang":"python","description":"This quickstart demonstrates how to connect to an AMQP broker (like RabbitMQ), declare a queue, publish a message, and consume messages asynchronously. It uses `os.environ.get` for the AMQP URL, making it easy to configure without hardcoding credentials. Remember to have a RabbitMQ instance running at `localhost:5672` or specify a different `AMQP_URL`."},"warnings":[{"fix":"Upgrade to Python 3.8+ or pin `aiormq` to a version less than 6.8.0 in your `requirements.txt`.","message":"Python 3.7 support was dropped in aiormq version 6.8.0. If you are using Python 3.7, you must upgrade your Python version or pin `aiormq<6.8.0`.","severity":"breaking","affected_versions":">=6.8.0"},{"fix":"Always wrap your AMQP operations in `try...finally` blocks to ensure `await connection.close()` and `await channel.close()` are called, even if exceptions occur. For channels, ensure they are closed before the connection.","message":"Properly closing connections and channels is crucial in asynchronous applications to prevent resource leaks and ensure graceful shutdown. Failing to `await connection.close()` and `await channel.close()` can lead to hung connections or unreleased resources.","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure your AMQP connection URL is properly URL-encoded, especially for parts like VHosts or usernames/passwords that might contain special characters. Test complex URLs thoroughly.","message":"While `aiormq` aims to handle AMQP URLs robustly, be mindful of special characters, complex VHosts, or non-standard query parameters in your connection string. Historically, there have been minor fixes related to URL parsing (e.g., slash unquoting in 6.8.1).","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-05-30T22:40:14.491Z","next_check":"2026-07-08T00:00:00.000Z","problems":[{"fix":"Install the package using pip: 'pip install aiormq'.","cause":"The 'aiormq' package is not installed in the Python environment.","error":"ModuleNotFoundError: No module named 'aiormq'"},{"fix":"Use 'from aiormq import Connection' and then 'connection = await Connection.connect()'.","cause":"The 'connect' function does not exist in the 'aiormq' module.","error":"ImportError: cannot import name 'connect' from 'aiormq'"},{"fix":"Access the 'Channel' class through an established connection: 'channel = await connection.channel()'.","cause":"The 'Channel' class is not directly accessible from the 'aiormq' module.","error":"AttributeError: module 'aiormq' has no attribute 'Channel'"},{"fix":"Ensure the connection is successfully established before calling methods: 'connection = await aiormq.connect()'.","cause":"Attempting to call a method on a 'None' object, possibly due to a failed connection.","error":"TypeError: 'NoneType' object is not callable"},{"fix":"Ensure the event loop is running when performing asynchronous operations: 'asyncio.run(main())'.","cause":"The asyncio event loop has been closed before the asynchronous operation could complete.","error":"RuntimeError: Event loop is closed"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"6.9.4","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/mosquito/aiormq","docs":"https://github.com/mosquito/aiormq/blob/master/README.rst","changelog":null,"pypi":"https://pypi.org/project/aiormq/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","http-networking"],"base_url":null,"auth_type":null,"install_checks":{"last_tested":"2026-05-30","tag":null,"tag_description":null,"installed_version":"6.9.0","pypi_latest":"6.9.4","is_stale":true,"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"aiormq","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.23,"mem_mb":8.4,"disk_size":"20.7M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"aiormq","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.27,"mem_mb":8.6,"disk_size":"21.1M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"aiormq","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3,"import_time_s":0.17,"mem_mb":8.4,"disk_size":"21M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"aiormq","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.2,"mem_mb":8.6,"disk_size":"22M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"aiormq","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.32,"mem_mb":9.6,"disk_size":"22.4M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"aiormq","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.4,"mem_mb":9.8,"disk_size":"22.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"aiormq","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.5,"import_time_s":0.28,"mem_mb":9.6,"disk_size":"23M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"aiormq","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.33,"mem_mb":9.8,"disk_size":"24M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"aiormq","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.51,"mem_mb":9.7,"disk_size":"14.3M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"aiormq","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.61,"mem_mb":9.8,"disk_size":"14.7M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"aiormq","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.1,"import_time_s":0.48,"mem_mb":9.7,"disk_size":"15M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"aiormq","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.54,"mem_mb":9.8,"disk_size":"16M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"aiormq","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.54,"mem_mb":10.2,"disk_size":"14.0M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"aiormq","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.6,"mem_mb":10.3,"disk_size":"14.3M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"aiormq","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.2,"import_time_s":0.47,"mem_mb":10.2,"disk_size":"15M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"aiormq","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.57,"mem_mb":10.3,"disk_size":"15M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"aiormq","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.2,"mem_mb":8.2,"disk_size":"21.0M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"aiormq","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.24,"mem_mb":8.3,"disk_size":"21.1M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"aiormq","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.6,"import_time_s":0.19,"mem_mb":8.2,"disk_size":"22M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"aiormq","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":0.21,"mem_mb":8.3,"disk_size":"22M"}]},"quickstart_checks":{"last_tested":"2026-04-25","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]},"_links":{"self":"https://checklist.day/api/registry/aiormq","v1":"https://checklist.day/v1/registry/aiormq","v1_install":"https://checklist.day/v1/registry/aiormq/install","v1_imports":"https://checklist.day/v1/registry/aiormq/imports","v1_compatibility":"https://checklist.day/v1/registry/aiormq/compatibility","v1_quickstart":"https://checklist.day/v1/registry/aiormq/quickstart","docs":"https://checklist.day/docs"}}