Skip to content

Commit 855bdca

Browse files
authored
Merge pull request #11 from dotkernel/issue-10
Issue #10: added documentation for DLQ and messenger configuration
2 parents 3521786 + 6a28e6a commit 855bdca

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Messenger Configuration
2+
3+
```php
4+
return [
5+
'symfony' => [
6+
'messenger' => [
7+
'transports' => [
8+
'redis_transport' => [
9+
// specifies the Redis server and stream/key
10+
// messages is the main stream where new messages are initially stored
11+
'dsn' => 'redis://127.0.0.1:6379/messages',
12+
// defines which serializer to use to encode/decode messages
13+
'serializer' => SymfonySerializer::class,
14+
'retry_strategy' => [
15+
// maximum number of retry attempts before moving a message to the failure transport
16+
'max_retries' => 3,
17+
// initial delay before retrying a failed message, in milliseconds
18+
'delay' => 1000,
19+
// each retry’s delay is multiplied by this factor
20+
'multiplier' => 2,
21+
// maximum delay allowed between retries, 0 means unlimited or default behavior
22+
'max_delay' => 0,
23+
],
24+
],
25+
// defines a transport named failed, used to store messages that cannot be delivered after retries.
26+
'failed' => [
27+
// specifies the Redis server and stream/key
28+
'dsn' => 'redis://127.0.0.1:6379/failed',
29+
// defines which serializer to use to encode/decode messages
30+
'serializer' => SymfonySerializer::class,
31+
],
32+
],
33+
// tells Symfony Messenger to send messages that exceed retry limits to the failed transport
34+
'failure_transport' => 'failed',
35+
],
36+
],
37+
'dependencies' => [
38+
'factories'> [
39+
'redis_transport' => [TransportFactory::class, 'redis_transport'],
40+
'failed' => [TransportFactory::class, 'failed'],
41+
SymfonySerializer::class => fn(ContainerInterface $container) => new PhpSerializer(),
42+
],
43+
],
44+
];
45+
```
46+
47+
## Main queue stream (`messages`)
48+
49+
`messages` stream is the main queue where all new messages are initially stored. The Messenger worker consume messages from this stream and attempt to process them according to the application logic.
50+
51+
## Dead Letter Queue (DLQ)
52+
53+
DLQ is a dedicated transport where messages are sent when they fail to be processed after a configured number of retries. Each transport can define a retry_strategy specifying the maximum number of retry attempts, delays between retries, and exponential backoff rules. When a message exceeds the allowed retries, it is automatically forwarded to the failure transport and stored in `failed` stream, ensuring that failed messages do not block the queue.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ nav:
1212
- "Understanding the Queue": v1/what-is-queue.md
1313
- Server Setup: v1/server-setup.md
1414
- Installation: v1/installation.md
15+
- Messenger Configuration: v1/messenger-configuration.md
1516
- Control Commands: v1/control-commands.md
1617
- Valkey: v1/valkey.md
1718
- How to:

0 commit comments

Comments
 (0)