public function work(Pheanstalk_Job $pJob) { try { $omekaJob = $this->_jobFactory->from($pJob->getData()); if (!$omekaJob) { throw new UnexpectedValueException("Job factory returned null (should never happen)."); } if ($omekaJob instanceof Omeka_Job_AbstractJob) { $user = $omekaJob->getUser(); if ($user) { Zend_Registry::get('bootstrap')->getContainer()->currentuser = $user; } } $omekaJob->perform(); $this->_pheanstalk->delete($pJob); } catch (Zend_Db_Exception $e) { // Bury any jobs with database problems aside from stale // connections, which should indicate to try the job a second time. if (strpos($e->getMessage(), 'MySQL server has gone away') === false) { $this->_pheanstalk->bury($pJob); } else { $this->_pheanstalk->release($pJob); } throw $e; } catch (Omeka_Job_Worker_InterruptException $e) { $this->_interrupt($omekaJob); $this->_pheanstalk->release($pJob); throw $e; } catch (Exception $e) { $this->_pheanstalk->bury($pJob); throw $e; } }
public function JobError() { $this->Log("Error! Uknown Job! Job ID: " . $this->job->getId()); $this->Log("Job Data: " . $this->job->getData()); $this->Log("Burying Job!"); $this->beanstalk->bury($this->job); }
/** * Get the raw body string for the job. * * @return string */ public function getRawBody() { return $this->job->getData(); }