0
votes

We are trying to use receive task in activiti to wait for some external events. When an external event occurs , we want to query all process instances based on process variable ( which we receive as part of event) and signal the instance to move forward. Also we want to show all waiting instance to the user.

When I looked at activiti API , I can see only see query to fetch executions based on activityId.

  1. I am looking to query all instances which are in receive task execution . ( probably with condition like where processVar1 = ?)
  2. Once I retrieve , I want to signal the instances.( which api should we use)

We are using Activiti 6.0

I am looking for some guidance with the available api to achieve this.

1

1 Answers

1
votes

Which version of Activiti are you using? The API of different versions of Activiti is slightly different, so the answer will also depend on which version you are using. Assuming you are using Activiti 6.0, which I'm familiar with:

With an execution query you can find process instances of a specific process definition, that are at a specific activity by activity id, like this:

List<Execution> executions = runtimeService.createExecutionQuery()
    .processDefinitionKey("procdefkey")
    .activityId("activityid")
    .list();

Use the id of the receive task as the activity id to find executions that are waiting in the receive task you're looking for.

If you want to include a check for a specific process variable value:

List<Execution> executions = runtimeService.createExecutionQuery()
    .processDefinitionKey("procdefkey")
    .activityId("activityid")
    .variableValueEquals("variablename", "variablevalue")
    .list();

To trigger a process instance to continue, use the trigger() method of RuntimeService. For example, to trigger all executions found with the query above:

for (Execution execution : executions) {
    runtimeService.trigger(execution.getId());
}