Hi Camunda team,
I have a spring boot application with camunda embedded.
I would like to call these apis call within the microservice itself or call through Java.
1 - GET localhost:8081/rest/process-instance?businessKey={id}
2 - GET localhost:8081/rest/job?processInstanceId={id}
3 - PUT localhost:8081/rest/job/{id}/retries
Is it possible? call these apis with JavaDelegate or the microservice api itself?
Niall
January 3, 2022, 2:18pm
2
It is indeed. If you’re running a JavaDelegate you’d have access to the engine’s JavaAPI so you can run any method that the REST API could enact.
Hi @Niall thank you for your reply, Can you tell me where I can find it in the documentation?
Niall
January 3, 2022, 2:21pm
4
Hello @Niall , thank you for your reply.
I tried to follow the documentation but when I try to retry an incident, it is creating a new one instead of retry the current incident.
My java code:
private void retryJob(String processInstanceId) {
ManagementService managementService = processEngine.getManagementService();
String jobId = managementService.createJobQuery().processInstanceId(processInstanceId)
.list()
.stream()
.findFirst()
.map(Job::getId)
.orElse(null);
managementService.setJobRetries(jobId, 1);
}
private String getProcessInstanceIdByBusinessId(String processDefinitionKey, String businessId) {
RuntimeService runtimeService = processEngine.getRuntimeService();
return runtimeService.createProcessInstanceQuery()
.processDefinitionKey(processDefinitionKey)
.list()
.stream()
.filter(processInstance -> processInstance.getBusinessKey().equalsIgnoreCase(businessId))
.findFirst()
.map(ProcessInstance::getProcessInstanceId)
.orElse(null);
}