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: scheduler.rst
+14-9Lines changed: 14 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -105,7 +105,7 @@ The :class:`Symfony\\Component\\Scheduler\\Attribute\\AsSchedule` attribute,
105
105
which by default references the schedule named ``default``, allows you to register
106
106
on a particular schedule::
107
107
108
-
// src/Scheduler/MyScheduleProvider.php
108
+
// src/Scheduler/SaleTaskProvider.php
109
109
namespace App\Scheduler;
110
110
111
111
#[AsSchedule]
@@ -260,7 +260,7 @@ Then, define your recurring message::
260
260
261
261
Finally, the recurring messages has to be attached to a schedule::
262
262
263
-
// src/Scheduler/MyScheduleProvider.php
263
+
// src/Scheduler/SaleTaskProvider.php
264
264
namespace App\Scheduler;
265
265
266
266
#[AsSchedule('uptoyou')]
@@ -336,15 +336,20 @@ recurring messages. You can narrow down the list to a specific schedule:
336
336
Efficient management with Symfony Scheduler
337
337
-------------------------------------------
338
338
339
-
If a worker becomes idle, the recurring messages won't be generated (because they
340
-
are created on-the-fly by the scheduler transport).
339
+
When a worker is restarted or undergoes shutdown for a period, the Scheduler transport won't be able to generate the messages (because they are created on-the-fly by the scheduler transport).
340
+
This implies that any messages scheduled to be sent during the worker's inactive period are not sent, and the Scheduler will lose track of the last processed message.
341
+
Upon restart, it will recalculate the messages to be generated from that point onward.
342
+
343
+
To illustrate, consider a recurring message set to be sent every 3 days.
344
+
If a worker is restarted on day 2, the message will be sent 3 days from the restart, on day 5.
345
+
346
+
While this behavior may not necessarily pose a problem, there is a possibility that it may not align with what you are seeking.
341
347
342
348
That's why the scheduler allows to remember the last execution date of a message
343
349
via the ``stateful`` option (and the :doc:`Cache component </components/cache>`).
344
-
This way, when it wakes up again, it looks at all the dates and can catch up on
345
-
what it missed::
350
+
This allows the system to retain the state of the schedule, ensuring that when a worker is restarted, it resumes from the point it left off.::
346
351
347
-
// src/Scheduler/MyScheduleProvider.php
352
+
// src/Scheduler/SaleTaskProvider.php
348
353
namespace App\Scheduler;
349
354
350
355
#[AsSchedule('uptoyou')]
@@ -366,7 +371,7 @@ To scale your schedules more effectively, you can use multiple workers. In such
366
371
cases, a good practice is to add a :doc:`lock </components/lock>` to prevent the
367
372
same task more than once::
368
373
369
-
// src/Scheduler/MyScheduleProvider.php
374
+
// src/Scheduler/SaleTaskProvider.php
370
375
namespace App\Scheduler;
371
376
372
377
#[AsSchedule('uptoyou')]
@@ -395,7 +400,7 @@ your message in a :class:`Symfony\\Component\\Messenger\\Message\\RedispatchMess
395
400
This allows you to specify a transport on which your message will be redispatched
396
401
before being further redispatched to its corresponding handler::
0 commit comments