acquire($job)) { return 'duplicate'; } $attempted = false; $contextAdded = false; try { if ($prepare !== null && ! $prepare()) { return 'stale'; } $this->addUniqueJobInformationToContext($job); $contextAdded = true; $attempted = true; Bus::dispatch($job); return 'accepted'; } finally { if ($contextAdded) { $this->removeUniqueJobInformationFromContext($job); } // A push error may follow acceptance. Keep its lease until the worker or expiry. if (! $attempted) { $lock->release($job); } } } }