/** * Handle an exception that occurred while the job was running. * * @param string $connection * @param \Viserio\Contracts\Queue\Job $job * @param int $delay * @param \Throwable $exception * * @throws \Throwable */ protected function handleJobException(string $connection, JobContract $job, int $delay, Throwable $exception) { // If we catch an exception, we will attempt to release the job back onto the queue // so it is not lost entirely. This'll let the job be retried at a later time by // another listener (or this same one). We will re-throw this exception after. try { if ($this->events !== null) { $this->events->trigger('viserio.job.exception.occurred', ['connection' => $connection, 'job' => $job, 'data' => json_decode($job->getRawBody(), true), 'exception' => $exception]); } } finally { if (!$job->isDeleted()) { $job->release($delay); } } throw $exception; }
/** * Removes this pattern's listener from all events to which it was * previously added. * * @param DispatcherContract $dispatcher */ public function unbind(DispatcherContract $dispatcher) { foreach ($this->events as $eventName => $value) { $dispatcher->detach($eventName, $this->getListener()); } $this->events = []; }