{"id":27603553,"url":"https://github.com/taskiq-python/taskiq-aio-pika","last_synced_at":"2025-04-22T19:17:34.002Z","repository":{"id":48413836,"uuid":"516881162","full_name":"taskiq-python/taskiq-aio-pika","owner":"taskiq-python","description":"AMQP broker for taskiq","archived":false,"fork":false,"pushed_at":"2025-04-20T23:31:36.000Z","size":256,"stargazers_count":30,"open_issues_count":10,"forks_count":12,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-20T23:46:14.732Z","etag":null,"topics":["amqp","queue","rabbitmq","taskiq","taskiq-broker"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/taskiq-python.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2022-07-22T20:39:40.000Z","updated_at":"2025-04-20T23:31:05.000Z","dependencies_parsed_at":"2024-01-19T17:03:03.539Z","dependency_job_id":"260ced1c-62f3-4646-a8b8-2e8f3d2b1f74","html_url":"https://github.com/taskiq-python/taskiq-aio-pika","commit_stats":{"total_commits":70,"total_committers":7,"mean_commits":10.0,"dds":"0.15714285714285714","last_synced_commit":"91b0e568e9ba355a7956fd8d5480a93dae5d753b"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taskiq-python%2Ftaskiq-aio-pika","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taskiq-python%2Ftaskiq-aio-pika/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taskiq-python%2Ftaskiq-aio-pika/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taskiq-python%2Ftaskiq-aio-pika/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taskiq-python","download_url":"https://codeload.github.com/taskiq-python/taskiq-aio-pika/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249985682,"owners_count":21356231,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["amqp","queue","rabbitmq","taskiq","taskiq-broker"],"created_at":"2025-04-22T19:17:33.500Z","updated_at":"2025-04-22T19:17:33.994Z","avatar_url":"https://github.com/taskiq-python.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AioPika broker for taskiq\n\nThis lirary provides you with aio-pika broker for taskiq.\n\nUsage:\n```python\nfrom taskiq_aio_pika import AioPikaBroker\n\nbroker = AioPikaBroker()\n\n@broker.task\nasync def test() -\u003e None:\n    print(\"nothing\")\n\n```\n\n## Non-obvious things\n\nYou can send delayed messages and set priorities to messages using labels.\n\n## Delays\n\n### **Default retries**\n\nTo send delayed message, you have to specify\ndelay label. You can do it with `task` decorator,\nor by using kicker.\nIn this type of delay we are using additional queue with `expiration` parameter and after with time message will be deleted from `delay` queue and sent to the main taskiq queue.\nFor example:\n\n```python\nbroker = AioPikaBroker()\n\n@broker.task(delay=3)\nasync def delayed_task() -\u003e int:\n    return 1\n\nasync def main():\n    await broker.startup()\n    # This message will be received by workers\n    # After 3 seconds delay.\n    await delayed_task.kiq()\n\n    # This message is going to be received after the delay in 4 seconds.\n    # Since we overriden the `delay` label using kicker.\n    await delayed_task.kicker().with_labels(delay=4).kiq()\n\n    # This message is going to be send immediately. Since we deleted the label.\n    await delayed_task.kicker().with_labels(delay=None).kiq()\n\n    # Of course the delay is managed by rabbitmq, so you don't\n    # have to wait delay period before message is going to be sent.\n```\n\n### **Retries with `rabbitmq-delayed-message-exchange` plugin**\n\nTo send delayed message you can install `rabbitmq-delayed-message-exchange`\nplugin https://github.com/rabbitmq/rabbitmq-delayed-message-exchange.\n\nAnd you need to configure you broker.\nThere is `delayed_message_exchange_plugin` `AioPikaBroker` parameter and it must be `True` to turn on delayed message functionality.\n\nThe delay plugin can handle tasks with different delay times well, and the delay based on dead letter queue is suitable for tasks with the same delay time.\nFor example:\n\n```python\nbroker = AioPikaBroker(\n    delayed_message_exchange_plugin=True,\n)\n\n@broker.task(delay=3)\nasync def delayed_task() -\u003e int:\n    return 1\n\nasync def main():\n    await broker.startup()\n    # This message will be received by workers\n    # After 3 seconds delay.\n    await delayed_task.kiq()\n\n    # This message is going to be received after the delay in 4 seconds.\n    # Since we overriden the `delay` label using kicker.\n    await delayed_task.kicker().with_labels(delay=4).kiq()\n```\n\n## Priorities\n\nYou can define priorities for messages using `priority` label.\nMessages with higher priorities are delivered faster.\nBut to use priorities you need to define `max_priority` of the main queue, by passing `max_priority` parameter in broker's init.\nThis parameter sets maximum priority for the queue and\ndeclares it as the prority queue.\n\nBefore doing so please read the [documentation](https://www.rabbitmq.com/priority.html#behaviour) about what\ndownsides you get by using prioritized queues.\n\n\n```python\nbroker = AioPikaBroker(max_priority=10)\n\n# We can define default priority for tasks.\n@broker.task(priority=2)\nasync def prio_task() -\u003e int:\n    return 1\n\nasync def main():\n    await broker.startup()\n    # This message has priority = 2.\n    await prio_task.kiq()\n\n    # This message is going to have priority 4.\n    await prio_task.kicker().with_labels(priority=4).kiq()\n\n    # This message is going to have priority 0.\n    await prio_task.kicker().with_labels(priority=None).kiq()\n\n```\n\n## Configuration\n\nAioPikaBroker parameters:\n* `url` - url to rabbitmq. If None, \"amqp://guest:guest@localhost:5672\" is used.\n* `result_backend` - custom result backend.\n* `task_id_generator` - custom task_id genertaor.\n* `exchange_name` - name of exchange that used to send messages.\n* `exchange_type` - type of the exchange. Used only if `declare_exchange` is True.\n* `queue_name` - queue that used to get incoming messages.\n* `routing_key` - that used to bind that queue to the exchange.\n* `declare_exchange` - whether you want to declare new exchange if it doesn't exist.\n* `max_priority` - maximum priority for messages.\n* `delay_queue_name` - custom delay queue name.\n    This queue is used to deliver messages with delays.\n* `dead_letter_queue_name` - custom dead letter queue name.\n    This queue is used to receive negatively acknowleged messages from the main queue.\n* `qos` - number of messages that worker can prefetch.\n* `declare_queues` - whether you want to declare queues even on\n    client side. May be useful for message persistance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaskiq-python%2Ftaskiq-aio-pika","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaskiq-python%2Ftaskiq-aio-pika","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaskiq-python%2Ftaskiq-aio-pika/lists"}