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
+35-1Lines changed: 35 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,9 +20,13 @@ You can send delayed messages and set priorities to messages using labels.
20
20
21
21
## Delays
22
22
23
+
### **Default retries**
24
+
23
25
To send delayed message, you have to specify
24
26
delay label. You can do it with `task` decorator,
25
-
or by using kicker. For example:
27
+
or by using kicker.
28
+
In 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.
29
+
For example:
26
30
27
31
```python
28
32
broker = AioPikaBroker()
@@ -48,6 +52,36 @@ async def main():
48
52
# have to wait delay period before message is going to be sent.
49
53
```
50
54
55
+
### **Retries with `rabbitmq-delayed-message-exchange` plugin**
56
+
57
+
To send delayed message you can install `rabbitmq-delayed-message-exchange`
There is `delayed_message_exchange_plugin``AioPikaBroker` parameter and it must be `True` to turn on delayed message functionality.
62
+
63
+
The 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.
64
+
For example:
65
+
66
+
```python
67
+
broker = AioPikaBroker(
68
+
delayed_message_exchange_plugin=True,
69
+
)
70
+
71
+
@broker.task(delay=3)
72
+
asyncdefdelayed_task() -> int:
73
+
return1
74
+
75
+
asyncdefmain():
76
+
await broker.startup()
77
+
# This message will be received by workers
78
+
# After 3 seconds delay.
79
+
await delayed_task.kiq()
80
+
81
+
# This message is going to be received after the delay in 4 seconds.
82
+
# Since we overriden the `delay` label using kicker.
0 commit comments