cancel
Showing results for 
Search instead for 
Did you mean: 

How to determine when process is complete after signal()?

gottsch
Champ in-the-making
Champ in-the-making
Hello,
I have an issue where I pass the process/execution a process variable, signal() it which executes tasks that work on the varaible, and then try to retrieve the variable again.  Everything works fine, unless the endEvent is encountered at which point the execution no longer exists and the variables are in history.  So my question is, how can I determine if the endEvent has occurred?

Snippet:

// get the process instance id from object
String piid = request.getProcessInstanceId();

// add the request process variable
runtimeService.setVariable(execution.getId(), "request", request);
      
// propagate process
runtimeService.signal(execution.getId());
      
// retrieve the request from the workflow
request = (IPncRequest) runtimeService.getVariable(piid, "request");


Thanks
2 REPLIES 2

slehman
Champ in-the-making
Champ in-the-making
Disclaimer - I'm just getting started with Activity.

It should be possible to tell whether it has ended based on the records in the database.  For example, if the execution is in ACT_RU_EXECUTION, I believe that means it hasn't reached an end event.  Or if the corresponding entry in ACT_HI_PROCINST has an end time, then it ended.   But there would be a race condition if you check that and take action, so perhaps even if it appear to be running, you need to handle the case where it completes before you can query the variable (if it fails, then check the history for the value).

Someone more experienced may have a better recommendation.

frederikherema1
Star Contributor
Star Contributor
Indeed, use the executionQuery() or processInstanceQuery() to find out if any result is returned or not when querying execution/process by id.

Or check the exception, it's of type ActivitiObjectNotFoundException() with a member field that indicates what entity is not found