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]); }
protected function setUp() { $this->messageReceiver = new StupidWorkflowProcessorMock(); $this->commandBus = new CommandBus(); $this->commandBus->utilize(new SingleTargetMessageRouter($this->messageReceiver)); $this->commandBus->utilize(new WorkflowProcessorInvokeStrategy()); $this->eventBus = new EventBus(); $this->eventBus->utilize(new SingleTargetMessageRouter($this->messageReceiver)); $this->eventBus->utilize(new WorkflowProcessorInvokeStrategy()); $locationTranslator = new LocationTranslator(['temp' => sys_get_temp_dir(), 'testdata' => $this->getTestDataPath()]); $this->fileGateway = new FileGateway(Bootstrap::getServiceManager()->get('prooph.link.fileconnector.file_type_adapter_manager'), Bootstrap::getServiceManager()->get('prooph.link.fileconnector.filename_renderer'), $locationTranslator); $workflowEngine = new RegistryWorkflowEngine(); $workflowEngine->registerCommandBus($this->commandBus, [NodeName::defaultName()->toString(), 'file-connector']); $workflowEngine->registerEventBus($this->eventBus, [NodeName::defaultName()->toString(), 'file-connector']); $this->fileGateway->useWorkflowEngine($workflowEngine); $this->tempPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR; }
/** * @return RegistryWorkflowEngine */ protected function getTestWorkflowEngine() { $workflowEngine = new RegistryWorkflowEngine(); $commandBus = new CommandBus(); $workflowEngine->registerCommandBus($commandBus, ['crm', 'online-shop']); $eventBus = new EventBus(); $workflowEngine->registerEventBus($eventBus, ['crm', 'wawi']); return $workflowEngine; }