cancel
Showing results for 
Search instead for 
Did you mean: 

How can I complete a Service task from within JavaDelegate? I want to complete a service using TaskService api.

ysagar
Champ in-the-making
Champ in-the-making

I have a simple workflow which basically completes a UserTask from within Service Task. The requirement is also to complete the service task as well. I am not able to obtain the currently running service task from within JavaDelegate. I want to pro grammatically complete the Service Task. Does Activiti store information about service task in ACT_RE_TASKINST table?

Any kind of help would be very much appreciated?

7 REPLIES 7

bassam_al-saror
Star Collaborator
Star Collaborator

Was the user task instance already created at the time the JavaDelegate got invoked? Sharing you process definition BPMN could help better understand what you are trying to achieve.

The objective is to complete all the user tasks which is already being created for a logged in user. The user task has its own workflow and is separate from Service task. The requirment is to create a service task and from the service task complete all the user tasks. I am able to complete all the user task. But when it comes to the point to complete the service task that's where I am facing exceptions. Here is XML part of process definition:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="ad-hoc">
<process id="ClarificationReceivedProcess" name="Clarification Received" isExecutable="true">
<startEvent id="startevent1" name="Start"></startEvent>
<endEvent id="endevent1" name="End"></endEvent>
<serviceTask id="ClarificationReceived" name="Clarification Received" activiti:class="activiti.util.HandleWaitForResponseTask"></serviceTask>
<sequenceFlow id="flow4" sourceRef="startevent1" targetRef="ClarificationReceived"></sequenceFlow>
<sequenceFlow id="flow5" sourceRef="ClarificationReceived" targetRef="endevent1"></sequenceFlow>
</process>

</definitions>

The service task does not need to be completed manually it will complete after the JavaDelegate execute method is called. 

Does Activiti store information about service task in ACT_RE_TASKINST table?

No, thats only for saving unfinished user tasks.

Does your JavaDelegate ("activiti.util.HandleWaitForResponseTask") block the execution?

No it does not. Is there a way to have Service Task completion event listener registered?