From cc182e48f97163fadae2e59824e1d9af4fbbbe1c Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Mon, 15 Jun 2026 22:47:38 +0330 Subject: [PATCH] refactor(scheduler): use the recipe's default stateful schedule Consolidate onto the symfony/scheduler recipe's App\Schedule (stateful + processOnlyLastMissedRun, so missed runs after downtime still execute) instead of a separate provider. Add the every-1-minute ExpireAppointmentsMessage there, point scheduler_default at schedule://default, and drop the redundant ExpireAppointmentsSchedule. debug:scheduler shows the trigger registered. Co-Authored-By: Claude Opus 4.8 --- config/packages/messenger.yaml | 2 +- .../Schedule/ExpireAppointmentsSchedule.php | 20 ------------------- src/Schedule.php | 9 +++++---- 3 files changed, 6 insertions(+), 25 deletions(-) delete mode 100644 src/Appointment/Schedule/ExpireAppointmentsSchedule.php diff --git a/config/packages/messenger.yaml b/config/packages/messenger.yaml index ce2c2a00..27f15c1a 100644 --- a/config/packages/messenger.yaml +++ b/config/packages/messenger.yaml @@ -12,7 +12,7 @@ framework: failed: 'doctrine://default?queue_name=failed' sync: 'sync://' scheduler_default: - dsn: 'schedule://appointment_expiry' + dsn: 'schedule://default' routing: 'App\Shared\Message\SendSmsMessage': async diff --git a/src/Appointment/Schedule/ExpireAppointmentsSchedule.php b/src/Appointment/Schedule/ExpireAppointmentsSchedule.php deleted file mode 100644 index 6c61b495..00000000 --- a/src/Appointment/Schedule/ExpireAppointmentsSchedule.php +++ /dev/null @@ -1,20 +0,0 @@ -add( - RecurringMessage::every('1 minute', new ExpireAppointmentsMessage()) - ); - } -} diff --git a/src/Schedule.php b/src/Schedule.php index bb3edce6..f06985a1 100644 --- a/src/Schedule.php +++ b/src/Schedule.php @@ -2,7 +2,9 @@ namespace App; +use App\Appointment\Message\ExpireAppointmentsMessage; use Symfony\Component\Scheduler\Attribute\AsSchedule; +use Symfony\Component\Scheduler\RecurringMessage; use Symfony\Component\Scheduler\Schedule as SymfonySchedule; use Symfony\Component\Scheduler\ScheduleProviderInterface; use Symfony\Contracts\Cache\CacheInterface; @@ -20,9 +22,8 @@ class Schedule implements ScheduleProviderInterface return (new SymfonySchedule()) ->stateful($this->cache) // ensure missed tasks are executed ->processOnlyLastMissedRun(true) // ensure only last missed task is run - - // add your own tasks here - // see https://symfony.com/doc/current/scheduler.html#attaching-recurring-messages-to-a-schedule - ; + ->add( + RecurringMessage::every('1 minute', new ExpireAppointmentsMessage()) + ); } }