You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can also queue tasks after the current run. This is handy when dispatching tasks in a scheduler. The scheduler
198
+
starts working on these tasks right away, but in nearly all cases you want to have these tasks in their regular queues, to be able
199
+
to use the priority system.
200
+
201
+
```php
202
+
use Symfony\Component\Scheduler\Attribute\AsSchedule;
203
+
use Symfony\Component\Scheduler\ScheduleProviderInterface;
204
+
use Symfony\Component\Scheduler\Schedule;
205
+
use Torr\TaskManager\Task\DispatchAfterRunTask\DispatchAfterRunTask;
206
+
207
+
#[AsSchedule]
208
+
class AppSchedule implements ScheduleProviderInterface
209
+
{
210
+
public function getSchedule() : Schedule
211
+
{
212
+
return new Schedule()
213
+
// ...
214
+
->add(RecurringMessage::cron(
215
+
"*/5 * * * *",
216
+
// we want to redispatch the task in the scheduler
217
+
new DispatchAfterRunTask(
218
+
new DownloadExternalFilesTask(),
219
+
),
220
+
));
221
+
}
222
+
}
223
+
```
224
+
225
+
226
+
:::warning
227
+
Symfony has a similar feature with the [`RedispatchMessage`], however in their implementation you need to explicitly specify the queue the task should go into (otherwise it will get dropped).
228
+
229
+
We want to keep using the default queue, so we have our own task for that.
230
+
:::
231
+
232
+
195
233
## Task Handlers
196
234
197
235
As this bundle builds on top of Symfony messages, you define your task handler as message handler:
0 commit comments