/** * @test */ public function it_creates_process_with_process_data_task_from_data_collected_message() { $processDefinition = ["process_type" => Definition::PROCESS_LINEAR_MESSAGING, "tasks" => [["task_type" => Definition::TASK_PROCESS_DATA, "target" => 'test-target', "allowed_types" => ['Prooph\\ProcessingTest\\Mock\\TargetUserDictionary', 'Prooph\\ProcessingTest\\Mock\\AddressDictionary'], "preferred_type" => 'Prooph\\ProcessingTest\\Mock\\AddressDictionary']]]; $wfMessage = $this->getUserDataCollectedTestMessage(); $factory = new ProcessFactory([$wfMessage->messageName() => $processDefinition]); $process = $factory->deriveProcessFromMessage($wfMessage, NodeName::defaultName()); $this->assertInstanceOf('Prooph\\Processing\\Processor\\LinearProcess', $process); $this->commandRouter->route(MessageNameUtils::getProcessDataCommandName('Prooph\\ProcessingTest\\Mock\\AddressDictionary'))->to($this->workflowMessageHandler); $process->perform($this->workflowEngine, $wfMessage); $receivedMessage = $this->workflowMessageHandler->lastWorkflowMessage(); $this->assertEquals('Prooph\\ProcessingTest\\Mock\\AddressDictionary', $receivedMessage->payload()->getTypeClass()); }
/** * @param WorkflowMessage $workflowMessage * @throws \Exception */ private function startProcessFromMessage(WorkflowMessage $workflowMessage) { $process = $this->processFactory->deriveProcessFromMessage($workflowMessage, $this->nodeName); $this->beginTransaction(); try { $process->perform($this->workflowEngine, $workflowMessage); $this->processRepository->add($process); $this->commitTransaction(); } catch (\Exception $ex) { $this->rollbackTransaction(); throw $ex; } $this->processorEventQueue->enqueue($this->events()->getNewActionEvent("process_was_started_by_message", $this, ["message_id" => $workflowMessage->uuid()->toString(), "message_name" => $workflowMessage->messageName(), "process_id" => $process->processId()->toString()])); }