How use the Java API inside the Spring Boot Embedded

Hi

I was using Camunda REST API for communication because my Engine Server were on Remote Server, but now I am using a Embedded Server with Spring Boot, so I would like to use the Java API directly, for example:

To create Tenant:

  Tenant tenant = identityService.newTenant(TENANT_ONE);
  tenant.setName("Tenant");
  identityService.saveTenant(tenant);

There is documentation for use the engine resources without REST API ?

1 Like

@cvinicius From this page each topic was explained with Java Api example.

https://docs.camunda.org/manual/latest/user-guide/process-engine/

In spring environment, you can autowire these process engine services.

ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

RepositoryService repositoryService = processEngine.getRepositoryService();
RuntimeService runtimeService = processEngine.getRuntimeService();
TaskService taskService = processEngine.getTaskService();
IdentityService identityService = processEngine.getIdentityService();
FormService formService = processEngine.getFormService();
HistoryService historyService = processEngine.getHistoryService();
ManagementService managementService = processEngine.getManagementService();
FilterService filterService = processEngine.getFilterService();
ExternalTaskService externalTaskService = processEngine.getExternalTaskService();
CaseService caseService = processEngine.getCaseService();
DecisionService decisionService = processEngine.getDecisionService();

@Component
public class MyService{
   
  @Autowired
  private IdentityService identityService;

  public void saveTenant(){
    Tenant tenant = identityService.newTenant(TENANT_ONE);
    tenant.setName("Tenant");
    identityService.saveTenant(tenant);
  }
}