File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ Contents
3131
3232 components
3333 locking
34+ retry
3435 quick-example
3536 symfony
3637
Original file line number Diff line number Diff line change 1+ Retry
2+ =====
3+ Some of the tasks which will be executed by a handler are risky and could fail
4+ (e.g. long running, i/o ...). To allow retry of this tasks the handler is able
5+ to implement the interface ``RetryTaskHandlerInterface `` and specify a maximum
6+ amount of attempts to pass the task.
7+
8+ The retries will be scheduled as soon as possible and the following tasks will
9+ be scheduled after this retry later. This prevent the following tasks to fail
10+ because of bad starting conditions because of the previous task.
11+
12+ Example
13+ *******
14+
15+ .. code-block :: php
16+
17+ <?php
18+
19+ include __DIR__ . '/vendor/autoload.php';
20+
21+ class ImageResizeHandler implements Task\Handler\TaskHandlerInterface, Task\Executor\RetryTaskHandlerInterface
22+ {
23+ public function handle($workload)
24+ {
25+ try {
26+ $this->doSomething();
27+ } catch (SpecificException $exception) {
28+ throw new FailedException($exception);
29+ }
30+
31+ // other exceptions will be propagated to the runner
32+ // the runner will retry the execution until the max-attempts are reached
33+ }
34+
35+ public function getMaximumAttempts()
36+ {
37+ return 3;
38+ }
39+ }
40+
41+
You can’t perform that action at this time.
0 commit comments