0
votes

I'm trying to get a specific Execution from a running process. In order to assure that there is nothing wrong with the filtering, I used a very simple query. All active Executions should be found. Exactly 1.

mProcessEngine = ProcessEngineConfiguration
          .createStandaloneInMemProcessEngineConfiguration()
          .buildProcessEngine();

RepositoryService repositoryService = mProcessEngine.getRepositoryService();
repositoryService.createDeployment().addClasspathResource( processFilePath).deploy();

Map<String, Object> variableMap = new HashMap<String, Object>();
RuntimeService runService = mProcessEngine.getRuntimeService();

ProcessInstance processInstance = runService.startProcessInstanceByKey( processId, variableMap);
List <Execution> executions = runService.createExecutionQuery().list();

The process instance gets started correctly, 2 tasks are executed until the process is waiting for a signal. This works as expected. But I don't get why the execution list is empty. If I query the Historic instances I get one result (as expected):

HistoryService historyService = mProcessHandler.getProcessEngine().getHistoryService();
List<HistoricProcessInstance> allInstances = historyService.createHistoricProcessInstanceQuery().list();

Any ideas what is wrong with the query?


Update I figured out that the execution list is empty (even after waiting for seconds) if the execution is waiting for a boundary event signal. If the boundary event is removed the execution list returns 1.

1

1 Answers

0
votes

This is just wild guess. Why you are getting RuntimeService on different ways, are you sure that those runtime services are same. Try to use same runSerivice

    ...  
    Map<String, Object> variableMap = new HashMap<String, Object>();
    RuntimeService runService = mProcessEngine.getRuntimeService();  
    ProcessInstance processInstance = runService.startProcessInstanceByKey( processId, variableMap);

    List <Execution> executions = runService.createExecutionQuery().list();

UPDATE

I have just tried this and works correctly on my machine with my activti process engine(custom configuration), didn't try with test engine(createStandaloneInMemProcessEngineConfiguration). Maybe you are fetching executions too early, so they are not started yet. Check if you have async flag set on your first task in process or try to delay fetching of the executions list.

I have no more ideas, so if nothing helps let me know to delete post, maybe someone else has better idea.