/**
  * @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
 /**
  * @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()));
 }
예제 #3
0
 /**
  * @return null|WorkflowMessage
  */
 public function previousWorkflowMessage()
 {
     if ($this->payload['previous_message']) {
         $sbMessage = RemoteMessage::fromArray($this->payload['previous_message']);
         return WorkflowMessage::fromServiceBusMessage($sbMessage);
     }
     return null;
 }
예제 #4
0
 /**
  * @test
  */
 public function it_translates_itself_to_service_bus_message_and_back()
 {
     $wfMessage = WorkflowMessage::collectDataOf(UserDictionary::prototype(), 'test-case', NodeName::defaultName()->toString(), array('metadata' => true));
     $sbMessage = $wfMessage->toServiceBusMessage();
     $this->assertInstanceOf('Prooph\\Common\\Messaging\\RemoteMessage', $sbMessage);
     $copyOfWfMessage = WorkflowMessage::fromServiceBusMessage($sbMessage);
     $this->assertInstanceOf('Prooph\\Processing\\Message\\WorkflowMessage', $copyOfWfMessage);
     $this->assertEquals(MessageNameUtils::MESSAGE_NAME_PREFIX . 'proophprocessingtestmockuserdictionary-collect-data', $copyOfWfMessage->messageName());
     $this->assertNull($copyOfWfMessage->payload()->extractTypeData());
     $this->assertEquals(array('metadata' => true), $copyOfWfMessage->metadata());
     $this->assertEquals(MessageNameUtils::COLLECT_DATA, $copyOfWfMessage->messageType());
     $this->assertEquals('test-case', $copyOfWfMessage->origin());
     $this->assertEquals(NodeName::defaultName()->toString(), $copyOfWfMessage->target());
 }