protected function createSubscription(ProcessEngine $engine, ?Job $job = null): void
    {
        $execution = $engine->findExecution($this->executionId);
        $nodeId = ($this->nodeId === null) ? null : $execution->getProcessModel()->findNode($this->nodeId)->getId();
        
        $data = [
            'id' => UUID::createRandom(),
            'execution_id' => $execution->getId(),
            'activity_id' => $this->activityId,
            'node' => $nodeId,
            'process_instance_id' => $execution->getRootExecution()->getId(),
            'flags' => $this->getSubscriptionFlag(),
            'boundary' => $this->boundaryEvent ? 1 : 0,
            'name' => $this->name,
            'created_at' => \time()
        ];
        
        if ($job !== null) {
            $data['job_id'] = $job->getId();
        }
        
        $engine->getConnection()->insert('#__bpmn_event_subscription', $data);
    }