{"id":9354,"library":"taskiq-aio-pika","title":"taskiq-aio-pika","description":"taskiq-aio-pika is a broker implementation for the Taskiq asynchronous task queue, enabling it to use RabbitMQ as a message broker. It leverages aio-pika for asynchronous AMQP communication, providing robust and scalable message passing. The current version is 0.6.0 and it typically follows the release cadence of the main Taskiq library.","status":"active","version":"0.6.0","language":"en","source_language":"en","source_url":"https://github.com/taskiq-python/taskiq-aio-pika","tags":["taskiq","rabbitmq","message-broker","async","aio-pika"],"install":[{"cmd":"pip install taskiq-aio-pika","lang":"bash","label":"Install core package"}],"dependencies":[{"reason":"Core Taskiq library, required for broker functionality.","package":"taskiq"},{"reason":"Asynchronous RabbitMQ client, used internally by the broker.","package":"aio-pika"}],"imports":[{"symbol":"AioPikaBroker","correct":"from taskiq_aio_pika import AioPikaBroker"}],"quickstart":{"code":"import os\nfrom taskiq import TaskiqSettings\nfrom taskiq_aio_pika import AioPikaBroker\n\n# Configure RabbitMQ connection using environment variable or a default\nRABBITMQ_URL = os.environ.get(\n    \"RABBITMQ_URL\",\n    \"amqp://guest:guest@localhost:5672/\"\n)\n\nclass AppSettings(TaskiqSettings):\n    \"\"\"Taskiq settings with AioPikaBroker for RabbitMQ.\"\"\"\n    broker: AioPikaBroker = AioPikaBroker(\n        url=RABBITMQ_URL,\n    )\n\n# Instantiate the settings\nsettings = AppSettings()\n\n# Define a task using the broker's decorator\n@settings.broker.task\nasync def process_data(data: str) -> str:\n    \"\"\"A simple task to process some data.\"\"\"\n    print(f\"Processing: {data}\")\n    return f\"Processed: {data.upper()}\"\n\n# To enqueue this task:\n# import asyncio\n# asyncio.run(process_data.kiq(data=\"hello world\"))\n\n# To run the worker (assuming this code is in `app_settings.py`):\n# taskiq worker app_settings:settings","lang":"python","description":"This quickstart demonstrates how to configure `taskiq-aio-pika` by defining a `TaskiqSettings` class with an `AioPikaBroker` instance pointing to your RabbitMQ server. A simple task `process_data` is then defined using the broker's decorator. To run the worker, execute `taskiq worker your_module_name:settings_instance` in your terminal."},"warnings":[{"fix":"Ensure RabbitMQ is running. Verify the `url` parameter passed to `AioPikaBroker` (e.g., `amqp://guest:guest@localhost:5672/`). Check firewall rules or Docker network configurations.","message":"RabbitMQ server must be running and accessible at the specified URL. If RabbitMQ is not running or the connection URL (e.g., host, port, credentials) is incorrect, the broker will fail to connect.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always check the release notes for both `taskiq` and `taskiq-aio-pika` when upgrading. Upgrade both libraries concurrently to compatible versions, as specified in `taskiq-aio-pika`'s `pyproject.toml` or `requirements.txt`.","message":"Major version updates of `taskiq` (e.g., `0.x` to `0.y` with significant changes) may introduce breaking changes to its internal APIs or settings structure that `taskiq-aio-pika` relies on. This can lead to unexpected errors or require broker updates.","severity":"breaking","affected_versions":"Potentially between `taskiq` major versions."},{"fix":"Use a virtual environment to manage dependencies. Ensure all packages requiring Pydantic are compatible with Pydantic v2. If a legacy dependency requires Pydantic v1, consider isolating environments or finding alternatives.","message":"Pydantic version conflicts can occur if other dependencies in your project require a different major version of Pydantic than what `taskiq` and `taskiq-aio-pika` expect. `taskiq-aio-pika` v0.6.0 is built for Pydantic v2.","severity":"gotcha","affected_versions":"All versions, depending on environment."}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Start your RabbitMQ server. Verify the RabbitMQ host and port in your `AioPikaBroker` URL (e.g., `localhost:5672`). Check network connectivity and firewall settings.","cause":"The RabbitMQ server is not running or is not accessible from the machine where the Taskiq worker is trying to connect.","error":"aio_pika.exceptions.AMQPConnectionError: [Errno 111] Connection refused"},{"fix":"Ensure the package is installed: `pip install taskiq-aio-pika`. Double-check the spelling of `AioPikaBroker` and `taskiq_aio_pika`.","cause":"The `taskiq-aio-pika` package is not installed, or there is a typo in the import statement.","error":"ImportError: cannot import name 'AioPikaBroker' from 'taskiq_aio_pika'"},{"fix":"Examine the application logs for earlier `aio-pika` connection errors (e.g., `Connection refused`, `Authentication failed`). Verify RabbitMQ server status, credentials, and network reachability. This error often surfaces after underlying connection issues.","cause":"The `AioPikaBroker` failed to establish a connection to RabbitMQ after initialization, or the connection was lost.","error":"taskiq.exceptions.TaskIQException: Broker is not connected."}]}