private function scheduleTaskFor(MessageHandler $messageHandler, ProcessingMetadata $taskMetadata, Message $workflowMessage)
    {
        if ($workflowMessage->messageType()->isCollectDataMessage()) {
            $taskType = TaskType::collectData();
        } elseif ($workflowMessage->messageType()->isDataCollectedMessage() || $workflowMessage->messageType()->isDataProcessedMessage()) {
            $taskType = TaskType::processData();
        } else {
            throw new \RuntimeException(
                sprintf(
                    "Failed to determine a task type which can handle a %s message",
                    $workflowMessage->messageType()->toString()
                )
            );
        }

        if (! empty($messageHandler->processingMetadata()->toArray())) {
            $taskMetadata = $taskMetadata->merge($messageHandler->processingMetadata());
        }

        return Task::setUp($messageHandler, $taskType, $workflowMessage->processingType(), $taskMetadata);
    }