コード例 #1
0
 /**
  * @param RemoteMessage $message
  * @return LogMessage|WorkflowMessage|StartSubProcess|SubProcessFinished
  * @throws \InvalidArgumentException
  */
 public function translateToProcessingMessage(RemoteMessage $message)
 {
     if (MessageNameUtils::isWorkflowMessage($message->name())) {
         return WorkflowMessage::fromServiceBusMessage($message);
     } else {
         if (MessageNameUtils::isProcessingLogMessage($message->name())) {
             return LogMessage::fromServiceBusMessage($message);
         } else {
             if (StartSubProcess::MSG_NAME === $message->name()) {
                 return StartSubProcess::fromServiceBusMessage($message);
             } else {
                 if (SubProcessFinished::MSG_NAME === $message->name()) {
                     return SubProcessFinished::fromServiceBusMessage($message);
                 }
             }
         }
     }
     throw new \InvalidArgumentException(sprintf('Message with name %s can not be translated. Unknown type provided.', $message->name()));
 }
コード例 #2
0
ファイル: WorkflowMessage.php プロジェクト: prooph/processing
 /**
  * @param RemoteMessage $aMessage
  * @return WorkflowMessage
  * @throws \RuntimeException
  */
 public static function fromServiceBusMessage(RemoteMessage $aMessage)
 {
     $payload = $aMessage->payload();
     Assertion::keyExists($payload, 'json');
     Assertion::keyExists($payload, 'origin');
     Assertion::keyExists($payload, 'target');
     $origin = $payload['origin'];
     $target = $payload['target'];
     $taskListPosition = isset($payload['processTaskListPosition']) ? TaskListPosition::fromString($payload['processTaskListPosition']) : null;
     $messagePayload = Payload::fromJsonDecodedData(json_decode($payload['json'], true));
     $metadata = isset($payload['metadata']) ? $payload['metadata'] : [];
     return new static($messagePayload, $aMessage->name(), $origin, $target, $metadata, $taskListPosition, $aMessage->header()->version(), $aMessage->header()->createdAt(), $aMessage->header()->uuid());
 }
コード例 #3
0
ファイル: Process.php プロジェクト: prooph/processing
 /**
  * @param LogMessageReceived $event
  */
 protected function whenLogMessageReceived(LogMessageReceived $event)
 {
     $taskListEntry = $this->taskList->getTaskListEntryAtPosition($event->taskListPosition());
     $sbMessage = RemoteMessage::fromArray($event->payload()['message']);
     $taskListEntry->logMessage(LogMessage::fromServiceBusMessage($sbMessage));
 }
コード例 #4
0
ファイル: TaskListEntry.php プロジェクト: prooph/processing
 protected function setLogFromArray(array $log)
 {
     foreach ($log as $sbMessageArr) {
         $sbMessage = RemoteMessage::fromArray($sbMessageArr);
         $this->log[] = LogMessage::fromServiceBusMessage($sbMessage);
     }
 }
コード例 #5
0
ファイル: StartSubProcess.php プロジェクト: prooph/processing
 /**
  * @return null|WorkflowMessage
  */
 public function previousWorkflowMessage()
 {
     if ($this->payload['previous_message']) {
         $sbMessage = RemoteMessage::fromArray($this->payload['previous_message']);
         return WorkflowMessage::fromServiceBusMessage($sbMessage);
     }
     return null;
 }
コード例 #6
0
 /**
  * @return WorkflowMessage|LogMessage
  * @throws \RuntimeException
  */
 public function lastMessage()
 {
     $sbMessage = RemoteMessage::fromArray($this->payload['last_message']);
     if (MessageNameUtils::isProcessingLogMessage($sbMessage->name())) {
         return LogMessage::fromServiceBusMessage($sbMessage);
     }
     if (MessageNameUtils::isWorkflowMessage($sbMessage->name())) {
         return WorkflowMessage::fromServiceBusMessage($sbMessage);
     }
     throw new \RuntimeException(sprintf("Sub process %s has received last a message with name %s that has no known message format", $this->processorNodeName() . '::' . $this->subProcessId(), $sbMessage->name()));
 }
コード例 #7
0
ファイル: LogMessage.php プロジェクト: prooph/processing
 /**
  * @param RemoteMessage $aMessage
  * @return LogMessage
  * @throws \RuntimeException
  */
 public static function fromServiceBusMessage(RemoteMessage $aMessage)
 {
     $payload = $aMessage->payload();
     Assertion::keyExists($payload, 'processTaskListPosition');
     Assertion::keyExists($payload, 'origin');
     Assertion::keyExists($payload, 'technicalMsg');
     Assertion::keyExists($payload, 'msgParams');
     Assertion::keyExists($payload, 'msgCode');
     $taskListPosition = TaskListPosition::fromString($payload['processTaskListPosition']);
     return new self($payload['origin'], $taskListPosition, $payload['technicalMsg'], $payload['msgCode'], $payload['msgParams'], $aMessage->header()->uuid(), $aMessage->header()->createdAt());
 }