Retrieve the status of an running process instance
Use the executionQuery() or processInstanceQuery() to find out ifany result is returned or not when querying execution/process byId.
runtimeService.createProcessInstanceQuery().processInstanceId(specifiedProcessInstanceId).singleResult()
runtimeService.createExecutionQuery().executionId(specifiedExecutionId).singleResult()
Specially when the history capabilities of Activiti engine isenabled:
- Specified process/execution instance id:
ProcessInstance inst = historyService.createHistoricProcessInstanceQuery().processInstanceId(specifiedProcessInstanceId).singleResult(); inst.isEnd()
- Unspecified process/execution instance id:
historyService.createHistoricProcessInstanceQuery().finished().list() historyService.createHistoricProcessInstanceQuery().unfinished().list()
Retrieve the active node of an running process instance
RuntimeService provide the API to retrieve the active node of anrunning process instance:
// Finds the activity ids for all executions that are waiting in activities.
// This is a list because a single activity can be active multiple times.
//
// @param executionId
// id of the execution, cannot be null.
// @throws ActivitiObjectNotFoundException
// when no execution exists with the given executionId.
List getActiveActivityIds(String executionId);
Its implementation work as below: The API usage in Activiti demo:
- org.activiti.rest.diagram.services.BaseProcessDefinitionDiagramLayoutResource: dead code org.activiti.rest.diagram.services.ProcessDefinitionDiagramLayoutResource doesn’t satisfy the condition to run getActiveActivityIds method. org.activiti.rest.diagram.services.ProcessInstanceDiagramLayoutResourceis not used in Activiti demo.
- org.activiti.rest.diagram.services.ProcessInstanceHighlightsResource: used to high light current active node and sequence flow
- org.activiti.explorer.ui.process.ProcessDefinitionImageStreamResourceBuilder: used to high light current active node
- org.activiti.rest.service.api.runtime.process.ExecutionActiveActivitiesCollectionResource: no usage in Activiti demo
- org.activiti.rest.service.api.runtime.process.ProcessInstanceDiagramResource: no usage in Activiti demo
Reference
Activiti user guide: history confiugration
Activiti Forums: ProcessInstance.isEnded() returns false
Activiti Forums: How to determine when process is complete after signal()?
Activiti Forums: any api to get the current node?