java - Is there an easy way to find out if the process is waiting in a UserTask inside Delegation Code? -
this question camunda bpm engine.
i implement executionlistener can attach process events. listener should send process state messages message queue. process message should contain state "pending" process if process waiting in usertask somewhere.
now wonder if there easy way find out if process waiting (somewhere) in usertask inside delegation code (by using provided delegateexecution
object of delegation code method). not find 1 far.
for example:
import org.camunda.bpm.engine.runtimeservice; import org.camunda.bpm.engine.delegate.delegateexecution; import org.camunda.bpm.engine.delegate.executionlistener; import org.camunda.bpm.engine.runtime.activityinstance; public class exampleexecutionlistener implements executionlistener { public void notify(delegateexecution execution) throws exception { runtimeservice runtimeservice = execution.getprocessengineservices().getruntimeservice(); activityinstance activityinstance = runtimeservice.getactivityinstance(execution.getprocessinstanceid()); boolean isinanyusertask = isinanyusertask(activityinstance); } protected boolean isinanyusertask(activityinstance activityinstance) { if ("usertask".equals(activityinstance.getactivitytype())) { return true; } else { (activityinstance child : activityinstance.getchildactivityinstances()) { boolean ischildinusertask = isinanyusertask(child); if (ischildinusertask) { return true; } } return false; } } }
note not consider called process instances.
Comments
Post a Comment