You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-6
Original file line number
Diff line number
Diff line change
@@ -116,6 +116,32 @@ async def main():
116
116
117
117
```
118
118
119
+
## Queue Types and Message Reliability
120
+
121
+
AioPikaBroker supports both classic and quorum queues. Quorum queues are a more modern queue type in RabbitMQ that provides better reliability and data safety guarantees.
122
+
123
+
```python
124
+
from taskiq_aio_pika import AioPikaBroker, QueueType
125
+
126
+
broker = AioPikaBroker(
127
+
queue_type=QueueType.QUORUM, # Use quorum queues for better reliability
When message processing fails due to consumer crashes (e.g. due to an OOM condition resulting in a SIGKILL), network issues, or other infrastructure problems, before the consumer has had the chance to acknowledge, positively or negatively, the message (and schedule a retry via taskiq's retry middleware), RabbitMQ will requeue the message to the front of the queue and it will be redelivered. With quorum queues, you can control how many times such a message will be redelivered:
135
+
136
+
- Set `max_attempts_at_message` to limit delivery attempts.
137
+
- Set `max_attempts_at_message=None` for unlimited attempts.
138
+
- This operates at the message delivery level, not application retry level. For application-level retries in case of exceptions that can be caught (e.g., temporary API failures), use taskiq's retry middleware instead.
139
+
- After max attempts, the message is logged and discarded.
140
+
-`max_attempts_at_message` requires using quorum queues (`queue_type=QueueType.QUORUM`).
141
+
142
+
This is particularly useful for preventing infinite loops of redeliveries of messages that consistently cause the consumer to crash ([poison messages](https://www.rabbitmq.com/docs/quorum-queues#poison-message-handling)) and can cause the queue to backup.
143
+
144
+
119
145
## Configuration
120
146
121
147
AioPikaBroker parameters:
@@ -125,13 +151,12 @@ AioPikaBroker parameters:
125
151
*`exchange_name` - name of exchange that used to send messages.
126
152
*`exchange_type` - type of the exchange. Used only if `declare_exchange` is True.
127
153
*`queue_name` - queue that used to get incoming messages.
154
+
*`queue_type` - type of RabbitMQ queue to use: `classic` or `quorum`. defaults to `classic`.
128
155
*`routing_key` - that used to bind that queue to the exchange.
129
156
*`declare_exchange` - whether you want to declare new exchange if it doesn't exist.
130
157
*`max_priority` - maximum priority for messages.
131
-
*`delay_queue_name` - custom delay queue name.
132
-
This queue is used to deliver messages with delays.
133
-
*`dead_letter_queue_name` - custom dead letter queue name.
134
-
This queue is used to receive negatively acknowleged messages from the main queue.
158
+
*`delay_queue_name` - custom delay queue name. This queue is used to deliver messages with delays.
159
+
*`dead_letter_queue_name` - custom dead letter queue name. This queue is used to receive negatively acknowleged messages from the main queue.
135
160
*`qos` - number of messages that worker can prefetch.
136
-
*`declare_queues` - whether you want to declare queues even on
137
-
client side. May be useful for message persistance.
161
+
*`declare_queues` - whether you want to declare queues even on client side. May be useful for message persistance.
162
+
*`max_attempts_at_message` - maximum number of attempts at processing the same message. requires the queue type to be set to `QueueType.QUORUM`. defaults to `20`for quorum queues and to `None` for classic queues. is not the same as task retries. pass `None` for unlimited attempts.
0 commit comments