spring-bootcamundabpmnbusiness-process-managementcamunda-modeler

How to create services objects from Camunda process Engine?


How you create Objects like userService or taskService from process engine in Camunda? my way is this:

@Inject
private TaskService taskService;

or

ProcessEngines.getDefaultProcessEngine().getTaskService();

Is there a better or more correct way for large projects?


Solution

  • Simply injecting the service you need in the bean is fine. It is the simplest way and gives you the benefits of Spring Beans.

    Prefer constructor based injection over field injection (e.g. Constructor injection vs Field injection) for easier testing and detection for cyclic dependencies.