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()) + ); } }