public function create($data) { if (!array_key_exists("collect_data_trigger", $data)) { return new ApiProblemResponse(new ApiProblem(422, 'Root key collect_data_trigger missing in request data')); } $data = $data["collect_data_trigger"]; if (!array_key_exists('processing_type', $data)) { return new ApiProblemResponse(new ApiProblem(422, 'Key processing_type is missing')); } $processingType = $data['processing_type']; if (!class_exists($processingType)) { return new ApiProblemResponse(new ApiProblem(422, 'Provided processing type is unknown')); } try { Assertion::implementsInterface($processingType, 'Prooph\\Processing\\Type\\Type'); } catch (\InvalidArgumentException $ex) { return new ApiProblemResponse(new ApiProblem(422, 'Provided processing type is not valid')); } $wfMessage = WorkflowMessage::collectDataOf($processingType::prototype(), __CLASS__, $this->ProcessingConfig->getNodeName()); $this->messageLogger->logIncomingMessage($wfMessage); $this->workflowEngine->dispatch($wfMessage); /** @var $response Response */ $response = $this->getResponse(); $response->getHeaders()->addHeaderLine('Location', $this->url()->fromRoute('prooph.link/processor_proxy/api/messages', ['id' => $wfMessage->uuid()->toString()])); $response->setStatusCode(201); return $response; }
/** * Message is only logged if it is has a valid type and is not logged already * otherwise it is ignored. * * @param $message */ private function tryLogMessage($message) { $messageId = null; if ($message instanceof RemoteMessage) { $messageId = $message->header()->uuid(); } elseif ($message instanceof ProcessingMessage) { $messageId = $message->uuid(); } if (!$messageId) { return; } $entry = $this->messageLogger->getEntryForMessageId($messageId); if ($entry) { return; } $this->messageLogger->logIncomingMessage($message); }