/**
  * @param Message $startMessage
  * @param Workflow $workflow
  * @return StartMessageWasAssignedToWorkflow
  */
 public static function record(Message $startMessage, Workflow $workflow)
 {
     $event = self::occur($workflow->workflowId()->toString(), ['start_message' => ['message_type' => $startMessage->messageType()->toString(), 'processing_type' => $startMessage->processingType()->of(), 'metadata' => $startMessage->processingMetadata()->toArray()]]);
     $event->workflowId = $workflow->workflowId();
     $event->startMessage = $startMessage;
     return $event;
 }
コード例 #2
0
 /**
  * Creates a new task for given message handler and workflow message
  *
  * @param MessageHandler $messageHandler
  * @param ProcessingMetadata $taskMetadata
  * @param Workflow\Message $workflowMessage
  * @return \Prooph\Link\ProcessManager\Model\Task
  * @throws \RuntimeException
  */
 private function scheduleTaskFor(MessageHandler $messageHandler, ProcessingMetadata $taskMetadata, Message $workflowMessage)
 {
     if ($workflowMessage->messageType()->isCollectDataMessage()) {
         $taskType = TaskType::collectData();
     } elseif ($workflowMessage->messageType()->isDataCollectedMessage() || $workflowMessage->messageType()->isDataProcessedMessage()) {
         $taskType = TaskType::processData();
     } else {
         throw new \RuntimeException(sprintf("Failed to determine a task type which can handle a %s message", $workflowMessage->messageType()->toString()));
     }
     if (!empty($messageHandler->processingMetadata()->toArray())) {
         $taskMetadata = $taskMetadata->merge($messageHandler->processingMetadata());
     }
     return Task::setUp($messageHandler, $taskType, $workflowMessage->processingType(), $taskMetadata);
 }
コード例 #3
0
 /**
  * @param Message $other
  * @return bool
  */
 public function equals(Message $other)
 {
     return $this->messageType()->equals($other->messageType()) && $this->processingType()->of() === $other->processingType()->of() && $this->processingMetadata()->toArray() === $other->processingMetadata()->toArray();
 }
コード例 #4
0
 /**
  * @param Message $message
  * @return bool
  */
 public function canHandleMessage(Message $message)
 {
     $this->lastValidationError = null;
     if (!$this->canHandleMessageType($message->messageType())) {
         $this->lastValidationError = sprintf("Message type %s is not supported.", $message->messageType());
         return false;
     }
     if ($message->processingMetadata()->shouldCollectionBeSplitIntoChunks()) {
         if (!$this->processingMetadata->canHandleChunks()) {
             $this->lastValidationError = "Unable to handle chunks.";
             return false;
         }
     }
     if (!$this->supportedProcessingTypes->isSupported($message->processingType())) {
         $this->lastValidationError = sprintf("Processing type %s is not supported. Supported types are: %s", $message->processingType()->of(), implode(", ", $this->supportedProcessingTypes->toArray()['processing_types']));
         return false;
     }
     return true;
 }