It is also possible to access the BPMN model instance by the process definition id using the Repository Service, as the following incomplete test sample code shows. Please see the generate-jsf-form quickstart for a complete example.

    1. public void testRepositoryService() {
    2. runtimeService.startProcessInstanceByKey(PROCESS_KEY);
    3. String processDefinitionId = repositoryService.createProcessDefinitionQuery()
    4. .processDefinitionKey(PROCESS_KEY).singleResult().getId();
    5. BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(processDefinitionId);
    6. }

    原文: https://docs.camunda.org/manual/7.9/user-guide/model-api/bpmn-model-api/respository-service/