cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Service task

k_kunti
Champ in-the-making
Champ in-the-making
Hi All

I am facing an issue in the service task… while instantiating a new process from it.

1. Initially I was creating runtime service in my java class implemented ActivityBehavior


public class DynamicProcessServiceTask implements ActivityBehavior{


   public void execute(ActivityExecution arg0) throws Exception {
      arg0.getActivity().getId();
      
   }

One of the key requirements is to access activity id … as done above

even after completion of the service task no entry was made in DB and the process could not progress further.

the I explicitly ended the activity by calling arg0.end();… this time the service task ended but the process could not progress further.


Then AS stated in the forum that its not a correct practice to create runtime service in own's java code…..I took the second path.

2. From my Java class I started calling REST services to initiate a new process… but still I am having the same issue… the process does not proceed beyond service task…


I Just altered my Java class to javaDelegate

DynamicProcessServiceTask implements JavaDelegate

Now the service task is getting completed….all the same I need the activity for the service task in ….

public void execute(DelegateExecution arg0) throws Exception {


Please suggest how to get the same.

Thanks in advance
Krish
3 REPLIES 3

mproch
Champ in-the-making
Champ in-the-making
Hi,
don't know if it helps, but when implementing ActivityBehaviour it's good to extend BpmnActivityBehaviour.
It has some helper methods, and then you basically do:

    public void execute(ActivityExecution execution) throws Exception {
         … <- here goes the real work
         performDefaultOutgoingBehavior(execution);
    }
The last line cause process to proceed.
Don't know if you can get activity object from JavaDelegate

sruiz
Champ in-the-making
Champ in-the-making
I had the same problem. I think that within the execute method of the ActivitiBehaviour  you should choose what sequence flow is going to take the service and signal it.

If you use JavaDelegate as interface it takes the after finishing execute method the next activity. Use it better.

To be confirmed by a developer.

jbarrez
Star Contributor
Star Contributor
Correct. From the userguide:

To implement a class that can be called during process execution, this class needs to implement the org.activiti.engine.delegate.JavaDelegate interface and provide the required logic in the execute method. When process execution arrives at this particular step, it will execute this logic defined in that method and leave the activity in the default BPMN 2.0 way.

[EXPERIMENTAL] It is also possible to provide a class that implements the org.activiti.engine.impl.pvm.delegate.ActivityBehavior interface. Implementations have then access to the more powerful ActivityExecution that for example also allows to influence the control flow of the process. Note however that this is not a very good practice, and should be avoided as much as possible. So, it is advised to use the ActivityBehavior interface only for advanced use cases and if you know exactly what you're doing.