Skip to content

Commit 0175292

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: [SCHEDULER] clarify idle state and stateful option
2 parents a3119c0 + f604e89 commit 0175292

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

scheduler.rst

Lines changed: 19 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]
@@ -282,7 +282,7 @@ Then, define your recurring message::
282282

283283
Finally, the recurring messages has to be attached to a schedule::
284284

285-
// src/Scheduler/MyScheduleProvider.php
285+
// src/Scheduler/SaleTaskProvider.php
286286
namespace App\Scheduler;
287287

288288
#[AsSchedule('uptoyou')]
@@ -362,15 +362,25 @@ recurring messages. You can narrow down the list to a specific schedule:
362362
Efficient management with Symfony Scheduler
363363
-------------------------------------------
364364

365-
If a worker becomes idle, the recurring messages won't be generated (because they
366-
are created on-the-fly by the scheduler transport).
365+
When a worker is restarted or undergoes shutdown for a period, the Scheduler
366+
transport won't be able to generate the messages (because they are created
367+
on-the-fly by the scheduler transport). This implies that any messages
368+
scheduled to be sent during the worker's inactive period are not sent, and the
369+
Scheduler will lose track of the last processed message. Upon restart, it will
370+
recalculate the messages to be generated from that point onward.
371+
372+
To illustrate, consider a recurring message set to be sent every 3 days. If a
373+
worker is restarted on day 2, the message will be sent 3 days from the restart,
374+
on day 5.
375+
376+
While this behavior may not necessarily pose a problem, there is a possibility
377+
that it may not align with what you are seeking.
367378

368379
That's why the scheduler allows to remember the last execution date of a message
369380
via the ``stateful`` option (and the :doc:`Cache component </components/cache>`).
370-
This way, when it wakes up again, it looks at all the dates and can catch up on
371-
what it missed::
381+
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.::
372382

373-
// src/Scheduler/MyScheduleProvider.php
383+
// src/Scheduler/SaleTaskProvider.php
374384
namespace App\Scheduler;
375385

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

395-
// src/Scheduler/MyScheduleProvider.php
405+
// src/Scheduler/SaleTaskProvider.php
396406
namespace App\Scheduler;
397407

398408
#[AsSchedule('uptoyou')]
@@ -421,7 +431,7 @@ your message in a :class:`Symfony\\Component\\Messenger\\Message\\RedispatchMess
421431
This allows you to specify a transport on which your message will be redispatched
422432
before being further redispatched to its corresponding handler::
423433

424-
// src/Scheduler/MyScheduleProvider.php
434+
// src/Scheduler/SaleTaskProvider.php
425435
namespace App\Scheduler;
426436

427437
#[AsSchedule('uptoyou')]

0 commit comments

Comments
 (0)