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 message to a data model.
  *
  * @param  Message $message [description]
  * @return R3H6\JobqueueDatabase\Domain\Model\Job
  */
 private function encodeJob(Message $message)
 {
     $job = new DatabaseJob();
     $job->setQueueName($this->name);
     $job->setPayload($message->getPayload());
     $job->setAttemps($message->getAttemps());
     $job->setState($message->getState());
     $job->setStarttime($message->getAvailableAt());
     return $job;
 }
Ejemplo n.º 3
0
 /**
  * @test
  */
 public function setStateForIntegerSetsState()
 {
     $this->subject->setState(12);
     $this->assertAttributeEquals(12, 'state', $this->subject);
 }