Skip to content

Commit eff2c5c

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: [SCHEDULER] clarify idle state and stateful option
2 parents 8be3779 + 0175292 commit eff2c5c

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
@@ -101,7 +101,7 @@ The :class:`Symfony\\Component\\Scheduler\\Attribute\\AsSchedule` attribute,
101101
which by default references the schedule named ``default``, allows you to register
102102
on a particular schedule::
103103

104-
// src/Scheduler/MyScheduleProvider.php
104+
// src/Scheduler/SaleTaskProvider.php
105105
namespace App\Scheduler;
106106

107107
#[AsSchedule]
@@ -268,7 +268,7 @@ Then, define your recurring message::
268268

269269
Finally, the recurring messages has to be attached to a schedule::
270270

271-
// src/Scheduler/MyScheduleProvider.php
271+
// src/Scheduler/SaleTaskProvider.php
272272
namespace App\Scheduler;
273273

274274
#[AsSchedule('uptoyou')]
@@ -344,15 +344,25 @@ recurring messages. You can narrow down the list to a specific schedule:
344344
Efficient management with Symfony Scheduler
345345
-------------------------------------------
346346

347-
If a worker becomes idle, the recurring messages won't be generated (because they
348-
are created on-the-fly by the scheduler transport).
347+
When a worker is restarted or undergoes shutdown for a period, the Scheduler
348+
transport won't be able to generate the messages (because they are created
349+
on-the-fly by the scheduler transport). This implies that any messages
350+
scheduled to be sent during the worker's inactive period are not sent, and the
351+
Scheduler will lose track of the last processed message. Upon restart, it will
352+
recalculate the messages to be generated from that point onward.
353+
354+
To illustrate, consider a recurring message set to be sent every 3 days. If a
355+
worker is restarted on day 2, the message will be sent 3 days from the restart,
356+
on day 5.
357+
358+
While this behavior may not necessarily pose a problem, there is a possibility
359+
that it may not align with what you are seeking.
349360

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

355-
// src/Scheduler/MyScheduleProvider.php
365+
// src/Scheduler/SaleTaskProvider.php
356366
namespace App\Scheduler;
357367

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

377-
// src/Scheduler/MyScheduleProvider.php
387+
// src/Scheduler/SaleTaskProvider.php
378388
namespace App\Scheduler;
379389

380390
#[AsSchedule('uptoyou')]
@@ -403,7 +413,7 @@ your message in a :class:`Symfony\\Component\\Messenger\\Message\\RedispatchMess
403413
This allows you to specify a transport on which your message will be redispatched
404414
before being further redispatched to its corresponding handler::
405415

406-
// src/Scheduler/MyScheduleProvider.php
416+
// src/Scheduler/SaleTaskProvider.php
407417
namespace App\Scheduler;
408418

409419
#[AsSchedule('uptoyou')]

0 commit comments

Comments
 (0)