Retry failed activity #241
-
Hi! Wondering if it's a missing feature or against any philosophy of the package but I would like to be able to retry workflows with failed activities (limited number of job tries). Why Issue Or am I looking at this all wrong? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is where it is important to make the distinction between workflow status and business status.
Exampleclass MyWorkflow extends Workflow
{
private bool $readyToRetry = false;
#[SignalMethod]
public function retry()
{
$this->readyToRetry = true;
}
public function execute()
{
while (true) {
try {
yield ActivityStub::make(MyRiskyActivity::class);
break; // Success, exit loop
} catch (\Throwable $e) {
// Pause until signal is received
yield WorkflowStub::await(fn () => $this->readyToRetry);
$this->readyToRetry = false; // reset flag for future retries
}
}
}
} What This Does
|
Beta Was this translation helpful? Give feedback.
This is where it is important to make the distinction between workflow status and business status.
Example