From 2d462ff663fee43b85d0519d5b68597a46365764 Mon Sep 17 00:00:00 2001 From: Saeed Hosseini <39903221+saeedhosseiinii@users.noreply.github.com> Date: Tue, 16 May 2023 18:25:30 +0330 Subject: [PATCH] [10.x] Add job timeout occurred event (#47068) * feat: add job timeout occurred event * fix style * formatting --------- Co-authored-by: Taylor Otwell --- src/Illuminate/Queue/Events/JobTimedOut.php | 33 +++++++++++++++++++++ src/Illuminate/Queue/Worker.php | 5 ++++ 2 files changed, 38 insertions(+) create mode 100644 src/Illuminate/Queue/Events/JobTimedOut.php diff --git a/src/Illuminate/Queue/Events/JobTimedOut.php b/src/Illuminate/Queue/Events/JobTimedOut.php new file mode 100644 index 000000000000..c36dea5352e3 --- /dev/null +++ b/src/Illuminate/Queue/Events/JobTimedOut.php @@ -0,0 +1,33 @@ +job = $job; + $this->connectionName = $connectionName; + } +} diff --git a/src/Illuminate/Queue/Worker.php b/src/Illuminate/Queue/Worker.php index d59e62fd1c1f..460f7b906e67 100644 --- a/src/Illuminate/Queue/Worker.php +++ b/src/Illuminate/Queue/Worker.php @@ -13,6 +13,7 @@ use Illuminate\Queue\Events\JobProcessed; use Illuminate\Queue\Events\JobProcessing; use Illuminate\Queue\Events\JobReleasedAfterException; +use Illuminate\Queue\Events\JobTimedOut; use Illuminate\Queue\Events\Looping; use Illuminate\Queue\Events\WorkerStopping; use Illuminate\Support\Carbon; @@ -223,6 +224,10 @@ protected function registerTimeoutHandler($job, WorkerOptions $options) $this->markJobAsFailedIfItShouldFailOnTimeout( $job->getConnectionName(), $job, $e ); + + $this->events->dispatch(new JobTimedOut( + $job->getConnectionName(), $job + )); } $this->kill(static::EXIT_ERROR, $options);