Skip to content

Commit 5942a35

Browse files
committed
[SCHEDULER] clarify idle state and stateful option
1 parent 8ac82c9 commit 5942a35

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

scheduler.rst

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ The :class:`Symfony\\Component\\Scheduler\\Attribute\\AsSchedule` attribute,
105105
which by default references the schedule named ``default``, allows you to register
106106
on a particular schedule::
107107

108-
// src/Scheduler/MyScheduleProvider.php
108+
// src/Scheduler/SaleTaskProvider.php
109109
namespace App\Scheduler;
110110

111111
#[AsSchedule]
@@ -260,7 +260,7 @@ Then, define your recurring message::
260260

261261
Finally, the recurring messages has to be attached to a schedule::
262262

263-
// src/Scheduler/MyScheduleProvider.php
263+
// src/Scheduler/SaleTaskProvider.php
264264
namespace App\Scheduler;
265265

266266
#[AsSchedule('uptoyou')]
@@ -336,15 +336,20 @@ recurring messages. You can narrow down the list to a specific schedule:
336336
Efficient management with Symfony Scheduler
337337
-------------------------------------------
338338

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.
341347

342348
That's why the scheduler allows to remember the last execution date of a message
343349
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.::
346351

347-
// src/Scheduler/MyScheduleProvider.php
352+
// src/Scheduler/SaleTaskProvider.php
348353
namespace App\Scheduler;
349354

350355
#[AsSchedule('uptoyou')]
@@ -366,7 +371,7 @@ To scale your schedules more effectively, you can use multiple workers. In such
366371
cases, a good practice is to add a :doc:`lock </components/lock>` to prevent the
367372
same task more than once::
368373

369-
// src/Scheduler/MyScheduleProvider.php
374+
// src/Scheduler/SaleTaskProvider.php
370375
namespace App\Scheduler;
371376

372377
#[AsSchedule('uptoyou')]
@@ -395,7 +400,7 @@ your message in a :class:`Symfony\\Component\\Messenger\\Message\\RedispatchMess
395400
This allows you to specify a transport on which your message will be redispatched
396401
before being further redispatched to its corresponding handler::
397402

398-
// src/Scheduler/MyScheduleProvider.php
403+
// src/Scheduler/SaleTaskProvider.php
399404
namespace App\Scheduler;
400405

401406
#[AsSchedule('uptoyou')]

0 commit comments

Comments
 (0)