cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the 'ActivityId' from an execution

jjfutt
Champ in-the-making
Champ in-the-making
Using Runtime Service, or Execution, how can we get the activity id of the current activity?

For example, consider the case of this simple process consisting of three Java Service tasks:
[attachment=0]MyProcess.png[/attachment]

Let's the the process instance id 1001. Then in the Java Delegate code, if we invoke:

execution.getProcessInstanceId(), it will be 1001
exeuction.getId() will also be 1001

When the process eventually goes through ServiceTask2 and ServiceTask3, the execution id will still be the same 1001. If we want to differentiate or identify the unique activity that is being executed, executionId doesn't point to such a unique id. However, it appears that activitiId will give us the name of that activiti as defined in the process definition and that's exactly what we want. How can we get this programmatically .. I see the activityIds() being stored in internal tables, just need to access the same in our Java handlers as well?

Thanks.
1 REPLY 1

schikkal
Champ in-the-making
Champ in-the-making
AFAIK, the execution Id will be same for all activities in a sequence. The execution Id changes for a parallel flows.

To get details of the activity in the java delegate, you can use org.activiti.engine.impl.pvm.delegate.ActivityExecution in the java delegate like here [1], but I am not sure if this is the right way to get the details as this class is in the impl package (not a public API).

[1] https://code.google.com/p/activiti-karaf/source/browse/trunk/activiti-karaf-examples/hello-activiti-...

Regards,
-Srinivasan