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

cancel
Showing results for 
Search instead for 
Did you mean: 
ysagar
Member II

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

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
bassam_al-saror
Alfresco Employee

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

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.

ysagar
Member II

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

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>

bassam_al-saror
Alfresco Employee

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

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?

ysagar
Member II

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

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

ysagar
Member II

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

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

bassam_al-saror
Alfresco Employee

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

You can use an execution listener (on end event), see the user guide Activiti User Guide 

daisuke-yoshimo
Senior Member

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

activiti.util.HandleWaitForResponseTask

> 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:

Please provide the source of service task and the stack trace of exception.