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
In both cases, the flags are optional. Keep in mind if both `start` and `end` are set, `limit` will not be applied, it's only used when one of `start` or `end` is missing.
Copy file name to clipboardExpand all lines: docs/book/v2/how-to/send-emails.md
+28-1Lines changed: 28 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,19 @@
1
1
# SEND EMAILS
2
2
3
+
## Summary
4
+
5
+
How to add background email sending to a Dotkernel application by importing Core
6
+
into the queue and following the `send-email` branch as a reference implementation.
7
+
8
+
## Details
9
+
3
10
Using a queuing service solves problems such as server overload. For example, if a server receives a large number of requests, it tries to process them synchronously, resulting in long response times or even server crashes.
4
11
5
12
A concrete example is sending emails. While a series of tasks are running on the server, a task such as sending an email is passed to a queue and run in the background so the server can move on to the next task, while the queue composes the email and sends it. Tasks are queued and processed gradually (FIFO), depending on available resources.
6
13
7
14
To implement such a service, the [`send-email`](https://github.com/dotkernel/queue/tree/send-email) branch can be taken as a model.
8
15
9
-
> **_NOTE:_** The default branch 1.0 holds only the base code of Queue and provides essential features such as:
16
+
> **_NOTE:_** The default branch holds only the base code of Queue and provides essential features such as:
10
17
>
11
18
> * Adding messages to the queue
12
19
> * Retrieving and processing messages (FIFO)
@@ -108,3 +115,23 @@ Inside your `config/autoload` folder create a new file named `mail.global.php`,
108
115
Once everything is installed and configured we can move on to handle the data in the queue. In the message handler for example `MessageHandler`, each message from the queue is processed, the email is composed, and then sent. By injecting the required services and using templates, the handler can send emails without blocking the main application, respecting FIFO and asynchronous processing.
109
116
110
117
In this [file](https://github.com/dotkernel/queue/blob/send-email/src/App/Message/MessageHandler.php) you can follow a simple example of how to create and send an email using data received from the queue inside the handler.
118
+
119
+
## FAQ
120
+
121
+
**Q: Do I need to modify the base queue code to send emails?**
122
+
123
+
A: No — import the `Core` module (copied in or as a submodule) and follow the
124
+
`send-email` branch as a model; the default branch already provides message queuing
125
+
and FIFO processing.
126
+
127
+
**Q: What does importing Core actually give the queue?**
128
+
129
+
A: Access to the main application's entities, services and configuration (cache,
130
+
mail, authentication, etc.), so the worker can compose and send real emails using
131
+
your existing templates.
132
+
133
+
**Q: Where do I configure the mailer itself?**
134
+
135
+
A: Create `config/autoload/mail.global.php` from the example in the `send-email`
136
+
branch and fill in your mail settings; the queue uses this to send emails in the
SymfonySerializer::class => fn(ContainerInterface $container) => new PhpSerializer(),
@@ -51,3 +59,36 @@ return [
51
59
## Dead Letter Queue (DLQ)
52
60
53
61
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.
62
+
63
+
## Application-level retry delays (`fail-safe`)
64
+
65
+
`config/autoload/local.php` also defines a separate `fail-safe` schedule, used to
66
+
delay re-adding a failed message to the queue:
67
+
68
+
```php
69
+
'fail-safe' => [
70
+
'first_retry' => 3600000, // 1h
71
+
'second_retry' => 43200000, // 12h
72
+
'third_retry' => 86400000, // 24h
73
+
],
74
+
```
75
+
76
+
This is independent of the transport-level `retry_strategy` above.
77
+
78
+
## FAQ
79
+
80
+
**Q: Where do the transport-level retry settings live?**
81
+
82
+
A: In `config/autoload/messenger.local.php`, under
Copy file name to clipboardExpand all lines: docs/book/v2/overview.md
+27-1Lines changed: 27 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,14 @@
1
1
# Overview
2
2
3
-
> [Dotkernel Queue](https://github.com/dotkernel/dot-queue) is a component based on [**Symfony Messenger**](https://github.com/symfony/messenger) that is used to queue asynchronous tasks.
3
+
## Summary
4
+
5
+
Dotkernel Queue is a Symfony Messenger-based component that lets Mezzio and Laminas
6
+
applications hand off slow or unreliable work to background workers instead of
7
+
processing it inline.
8
+
9
+
## Details
10
+
11
+
> [Dotkernel Queue](https://github.com/dotkernel/queue) is a component based on [**Symfony Messenger**](https://github.com/symfony/messenger) that is used to queue asynchronous tasks.
4
12
[netglue/laminas-messenger](https://github.com/netglue/laminas-messenger) is an adapter that integrates Symfony Messenger with the [Laminas Service Manager](https://docs.laminas.dev/laminas-servicemanager/) container for Mezzio/Laminas applications.
5
13
6
14
Some everyday **operations are time-consuming and resource-intensive**, so it's best if they run on separate machines, decoupled from the regular request-response cycle.
@@ -23,3 +31,21 @@ It allows the main platform to return a response and remain responsive for new r
0 commit comments