Skip to content

Commit 05cfd12

Browse files
committed
update for Symfony PR 58001
Add doc for add capability to skip missed periodic tasks, only the last schedule will be called Update scheduler.rst
1 parent f1c7127 commit 05cfd12

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

scheduler.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,27 @@ This allows the system to retain the state of the schedule, ensuring that when a
889889
}
890890
}
891891

892+
With ``stateful`` option, All missed messages will be handled, If you nedd handle your message only once you can use the ``setHeapOnlyOnce`` option.::
893+
894+
// src/Scheduler/SaleTaskProvider.php
895+
namespace App\Scheduler;
896+
897+
#[AsSchedule('uptoyou')]
898+
class SaleTaskProvider implements ScheduleProviderInterface
899+
{
900+
public function getSchedule(): Schedule
901+
{
902+
$this->removeOldReports = RecurringMessage::cron('3 8 * * 1', new CleanUpOldSalesReport());
903+
904+
return $this->schedule ??= (new Schedule())
905+
->with(
906+
// ...
907+
)
908+
->stateful($this->cache)
909+
->setHeapOnlyOnce(true)
910+
}
911+
}
912+
892913
To scale your schedules more effectively, you can use multiple workers. In such
893914
cases, a good practice is to add a :doc:`lock </components/lock>` to prevent the
894915
same task more than once::

0 commit comments

Comments
 (0)