public function reserve(DatabaseJob $job)
 {
     $job->setState(Message::STATE_RESERVED);
     $where = 'state!=' . (int) Message::STATE_RESERVED . ' AND uid=' . (int) $job->getUid();
     $fields = ['state' => Message::STATE_RESERVED];
     $this->getDatabaseConnection()->exec_UPDATEquery($this->table, $where, $fields);
     return $this->getDatabaseConnection()->sql_affected_rows() === 1;
 }
 /**
  * Converts a data model into a message.
  *
  * @param  R3H6\JobqueueDatabase\Domain\Model\Job $job
  * @return Message
  */
 private function decodeJob(DatabaseJob $job)
 {
     $message = new Message($job->getPayload(), $job->getUid());
     $message->setState($job->getState());
     $message->setAttemps($job->getAttemps());
     return $message;
 }
Пример #3
0
 /**
  * @test
  */
 public function setTstampForDateTimeSetsTstamp()
 {
     $dateTimeFixture = new \DateTime();
     $this->subject->setTstamp($dateTimeFixture);
     $this->assertAttributeEquals($dateTimeFixture, 'tstamp', $this->subject);
 }