/**
  * @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
 /**
  * Checks if the message handler can handle a workflow message with the item processing type of a collection.
  *
  * @param Message $message
  * @param MessageHandler $messageHandler
  * @return bool
  */
 private function isForeachProcessPossible(Message $message, MessageHandler $messageHandler)
 {
     if ($message->processingType()->typeDescription()->nativeType() !== NativeType::COLLECTION) {
         return false;
     }
     $itemMessage = Message::emulateProcessingWorkflowMessage($message->messageType(), $message->processingType()->typeProperties()['item']->typePrototype(), $message->processingMetadata());
     return $messageHandler->canHandleMessage($itemMessage);
 }
예제 #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();
 }
 /**
  * @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;
 }