public function getTaskResultFromMessage(OutputMessage $message)
 {
     $data = $message->getData();
     $type = substr($data, 0, 1);
     $serializedData = substr($data, 1);
     if ($type === 'r') {
         $return = unserialize($serializedData);
         $taskResult = TaskResult::fromReturn($return);
     } elseif ($type === 'e') {
         list($class, $message, $code, $file, $line, ) = unserialize($serializedData);
         $exception = $this->createResultException($class);
         $this->setResultExceptionInternalData($exception, $class, $message, $code, $file, $line);
         $taskResult = TaskResult::fromException($exception);
     } else {
         $taskResult = TaskResult::fromReturn(null);
     }
     return $taskResult;
 }
Esempio n. 2
0
 /**
  * @param string $type
  * @param InputMessageIdentifier $identifier
  * @param OutputMessage $outputMessage
  */
 public function putOutput($type, InputMessageIdentifier $identifier, OutputMessage $outputMessage)
 {
     $messageId = $identifier->getId();
     $captureResult = 'MessageNotFinished' === $this->redis->hGet($this->getMessageResultKey($type), $messageId);
     $this->redis->multi();
     $this->redis->lRem($this->getMessageRunKey($type), $messageId, 0);
     $this->redis->hDel($this->getMessageStartTimeKey($type), $messageId);
     $this->redis->lRem($this->getMessageQueueKey($type), $messageId, 0);
     $this->redis->hDel($this->getMessageQueueTimeKey($type), $messageId);
     $this->redis->hDel($this->getMessageKey($type), $messageId);
     if ($captureResult) {
         $data = $outputMessage->getData();
         $this->redis->hSet($this->getMessageResultKey($type), $messageId, $data);
         $this->redis->lPush($this->getMessageResultReadyKey($type, $messageId), 'true');
     }
     $this->redis->exec();
 }