public static function delete(Job $job) { if ($job->getQueueId()) { $pheanstalk = new Pheanstalk(Config::getInstance()->get('Octo.worker.host')); try { $beanstalkJob = $pheanstalk->peek($job->getQueueId()); $pheanstalk->delete($beanstalkJob); } catch (\Exception $ex) { // Job is not in beanstalk. } } self::getStore()->delete($job); }
/** * Delete message from queue * * @param int $pid * @param callable $callback function handler * @throws \Deliveries\Exceptions\BrokerException * @return boolean */ public function delete($pid = null, callable $callback = null) { try { // get broker job by process id $job = $this->broker->peek($pid); // remove process $this->broker->delete($job); if (is_null($callback) === false) { $callback(); } return true; } catch (Exception $e) { throw new BrokerException($e->getMessage()); } }
/** * @inheritdoc */ public function finish($messageId) { $pheanstalkJob = $this->client->peek((int) $messageId); $this->client->delete($pheanstalkJob); return true; }
/** * * @param string $identifier * @return Message */ public function getMessage($identifier) { $pheanstalkJob = $this->client->peek($identifier); return $this->decodeMessage($pheanstalkJob->getData()); }
/** * @param Pheanstalk $connection * @param $id * @return object|\Pheanstalk\Job */ public function getJob(Pheanstalk $connection, $id) { $job = $connection->peek($id); return $job; }
/** * @param $jobId */ public function removeJob($jobId) { $this->connection->delete($this->connection->peek($jobId)); }