cancel
Showing results for 
Search instead for 
Did you mean: 

How to get taskentity id from service task?

kesavkolla
Champ in-the-making
Champ in-the-making
I've a service task class which implements JavaDelegate.  Inside the execute method I want to get the current running task entity id.  Is there any API to retrieve the current running task entity id?
13 REPLIES 13

jbarrez
Star Contributor
Star Contributor
I guess you need the id of the activity which you are currently in?

Why do you need? What's the use case?

kesavkolla
Champ in-the-making
Champ in-the-making
I have a service task which executes a remote command (SSH).  I want to pass the id to the remote program as a co-relation id.  The remote program generates some messages and I want to co-relate those messages with the task id.  Is there any way to get the task entity id into the service task.  I can get activity id but it's not a unique as task entity id.

jbarrez
Star Contributor
Star Contributor
Then you should use the execution id, which you can easily get from the DelegateExecution.

Correlate using that id, and you can signal your process back using the singal method on the runtimeService.

kesavkolla
Champ in-the-making
Champ in-the-making
I have a parallel gateway in my flow.  The execution id is same for both branches in the flow.  That is the reason I want to get the actual runtime id of the task.  Is it not possible to get the id of the current running task?

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
are you sure they are the same? Afaik, each leg of a parallel gateway should have its own id. And watch out, do not use the root execution, since that is indeed the same for both.

kesavkolla
Champ in-the-making
Champ in-the-making
The service task gets DelegateExecution as reference.  If I call getId on it I'm getting same id in both the parallel gateway flows.
I have same service task class that is plugged into the parallel gateway with different parameters.  In the runtime if when I call getId on the delegate execution object I'm getting same id.

frederikherema1
Star Contributor
Star Contributor
Can you provide a simple unit-test with a parallel process which highlight the behavior of the same ID's in parallel paths?

vnama
Champ in-the-making
Champ in-the-making
I'd like to do a similar thing. I have an application from which a service task in a process must communicate to. I would like the service task or any task for that matter, to be able to communicate to my rest application it's task id. Once my application has the task id, I will make a rest call to the Activiti-rest. But I need the id of the task. How can I get the id of a service task? Thank you.

jbarrez
Star Contributor
Star Contributor
Why would you want to do that? Isn't an execution id enough, as the correlation between your exchanged messages