AnsweredAssumed Answered

Detect ended process instance

Question asked by dibrandt on Feb 27, 2014
Latest reply on Mar 1, 2014 by trademak

we use this method to detect a ended process instance.
We call the method after the engine fired an event at the end event node.
Is this the best method to detect a ended instance? Is the List<Execution> always empty?  Or exists a other solution?

    public void detectProcStatusFromActivity() {
        if(this.status == null) {
            if (this.processInstanceId == null) {
                LOG.debug("Could not detect processState without processInstanceId");
            } else {
                try {
                    List<Execution> executions = getActivitiRuntimeService().createExecutionQuery()
                    if (executions.isEmpty()) {
                        this.status = ProcStatus.CLOSED;
                } catch (ActivitiException e) {
                            "Exception while trying to find Activiti process instance for instanceId {}, " +
                            "assuming new process state: CLOSED.",  processInstanceId, e);
                    this.status = ProcStatus.CLOSED;