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 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-15 22:47:38 +03:30
co-authored by Claude Opus 4.8
parent 71ab8892c9
commit cc182e48f9
3 changed files with 6 additions and 25 deletions
+1 -1
View File
@@ -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
@@ -1,20 +0,0 @@
<?php
namespace App\Appointment\Schedule;
use App\Appointment\Message\ExpireAppointmentsMessage;
use Symfony\Component\Scheduler\Attribute\AsSchedule;
use Symfony\Component\Scheduler\RecurringMessage;
use Symfony\Component\Scheduler\Schedule;
use Symfony\Component\Scheduler\ScheduleProviderInterface;
#[AsSchedule('appointment_expiry')]
final class ExpireAppointmentsSchedule implements ScheduleProviderInterface
{
public function getSchedule(): Schedule
{
return (new Schedule())->add(
RecurringMessage::every('1 minute', new ExpireAppointmentsMessage())
);
}
}
+5 -4
View File
@@ -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())
);
}
}