Пример #1
0
 /**
  * @param Task $task
  * @param WorkflowMessage $message
  * @return bool
  */
 private function isCorrectMessageFor(Task $task, WorkflowMessage $message)
 {
     if (MessageNameUtils::isProcessingCommand($message->messageName())) {
         if (!$task instanceof CollectData || $message->messageName() !== MessageNameUtils::getCollectDataCommandName($task->prototype()->of())) {
             return false;
         }
     }
     return true;
 }
Пример #2
0
 /**
  * @return string
  */
 public function messageName()
 {
     switch ($this->messageType()->toString()) {
         case MessageType::TYPE_DATA_PROCESSED:
             return MessageNameUtils::getDataProcessedEventName($this->processingType()->of());
         case MessageType::TYPE_PROCESS_DATA:
             return MessageNameUtils::getProcessDataCommandName($this->processingType()->of());
         case MessageType::TYPE_DATA_COLLECTED:
             return MessageNameUtils::getDataCollectedEventName($this->processingType()->of());
         case MessageType::TYPE_COLLECT_DATA:
             return MessageNameUtils::getCollectDataCommandName($this->processingType()->of());
     }
 }
Пример #3
0
 /**
  * @param Prototype $aPrototype
  * @param string|NodeName $origin
  * @param string|NodeName $target
  * @param array $metadata
  * @return WorkflowMessage
  */
 public static function collectDataOf(Prototype $aPrototype, $origin, $target, array $metadata = [])
 {
     $messageName = MessageNameUtils::getCollectDataCommandName($aPrototype->of());
     return new static(Payload::fromPrototype($aPrototype), $messageName, $origin, $target, $metadata);
 }
Пример #4
0
 protected function setUpOtherMachine()
 {
     $this->otherMachineWorkflowMessageHandler = new TestWorkflowMessageHandler();
     $commandBus = new CommandBus();
     $this->otherMachineCommandRouter = new CommandRouter();
     $this->otherMachineCommandRouter->route(MessageNameUtils::getCollectDataCommandName('Prooph\\ProcessingTest\\Mock\\UserDictionaryS2'))->to($this->otherMachineWorkflowMessageHandler);
     $this->otherMachineCommandRouter->route(MessageNameUtils::getProcessDataCommandName('Prooph\\ProcessingTest\\Mock\\TargetUserDictionary'))->to($this->otherMachineWorkflowMessageHandler);
     $commandBus->utilize($this->otherMachineCommandRouter);
     $commandBus->utilize(new HandleWorkflowMessageInvokeStrategy());
     $commandBus->utilize(new WorkflowProcessorInvokeStrategy());
     $commandBus->utilize(new ToProcessingMessageTranslator());
     $this->otherMachineWorkflowEngine = new RegistryWorkflowEngine();
     $this->otherMachineWorkflowEngine->registerCommandBus($commandBus, ['test-case', 'test-target', 'other_machine']);
     //Add second command bus to local workflow engine to forward StartSubProcess command to message dispatcher
     $this->otherMachineMessageDispatcher = new InMemoryRemoteMessageDispatcher($commandBus, new EventBus());
     $parentNodeCommandBus = new CommandBus();
     $parentCommandRouter = new CommandRouter();
     $parentCommandRouter->route(StartSubProcess::MSG_NAME)->to($this->otherMachineMessageDispatcher);
     $parentNodeCommandBus->utilize($parentCommandRouter);
     $parentNodeCommandBus->utilize(new ForwardToRemoteMessageDispatcherStrategy(new FromProcessingMessageTranslator()));
     $this->workflowEngine->registerCommandBus($parentNodeCommandBus, ['other_machine']);
     $this->getOtherMachineWorkflowProcessor();
     //Add event buses to handle SubProcessFinished event
     $parentNodeEventBus = new EventBus();
     $parentNodeEventRouter = new EventRouter();
     $parentNodeEventBus->utilize(new SingleTargetMessageRouter($this->getTestWorkflowProcessor()));
     $parentNodeEventBus->utilize(new ToProcessingMessageTranslator());
     $parentNodeEventBus->utilize(new WorkflowProcessorInvokeStrategy());
     $otherMachineEventBus = new EventBus();
     $toParentNodeMessageDispatcher = new InMemoryRemoteMessageDispatcher(new CommandBus(), $parentNodeEventBus);
     $otherMachineEventBus->utilize(new SingleTargetMessageRouter($toParentNodeMessageDispatcher));
     $otherMachineEventBus->utilize(new ForwardToRemoteMessageDispatcherStrategy(new FromProcessingMessageTranslator()));
     $this->otherMachineWorkflowEngine->registerEventBus($otherMachineEventBus, [Definition::DEFAULT_NODE_NAME]);
 }
Пример #5
0
 /**
  * @test
  */
 public function it_returns_a_collect_data_command_name_including_the_type_class_normalized()
 {
     $commandName = MessageNameUtils::getCollectDataCommandName('Prooph\\ProcessingTest\\Mock\\UserDictionary');
     $this->assertEquals(MessageNameUtils::MESSAGE_NAME_PREFIX . 'proophprocessingtestmockuserdictionary-collect-data', $commandName);
 }