cancel
Showing results for 
Search instead for 
Did you mean: 

MI User task followed by a Service Task

luisalves00
Champ in-the-making
Champ in-the-making
Hello,

Part of my workflow goes like this:


<blockcode>
      <userTask id="Auth-Request-Program"
         name="Program Auth (${requestN} / ${programmerGroupItem.name})"
         activiti:candidateUsers="${programmerGroupItem.programadores}">
            <extensionElements>
                <activiti:taskListener event="create" class="org.flow.activiti.SetPriorityTaskListener">
                    <activiti:field name="priority" stringValue="1" />
                </activiti:taskListener>
                <activiti:taskListener event="create" class="org.flow.activiti.SetProgrammingIdTaskListener" />
            </extensionElements>
            <multiInstanceLoopCharacteristics isSequential="false">
                <loopDataInputRef>programmerGroupList</loopDataInputRef>
                <inputDataItem name="programmerGroupItem" />
            </multiInstanceLoopCharacteristics>
        </userTask>
      
      <sequenceFlow id="flow18" name="" sourceRef="Auth-Request-Program"
         targetRef="servicetask6">
        </sequenceFlow>
      
      <serviceTask id="servicetask6" name="Finally Create Auths"
         activiti:class="org.flow.activiti.authRequest.CreateAuthorizationFromRequestProgramador">
        </serviceTask>
</blockcode>

So…when a group of users finish all task the service task is executed.

PROBLEM: when the last user finish his task, the 'servicetask6' executes and fails, but the user task seems to be completed anyway. Is it supposed to work this way? I was expecting the last User Task to be sync with the following Service Task. Now how can I re-execute the 'servicetask6' ?

thanks in advance.
6 REPLIES 6

frederikherema1
Star Contributor
Star Contributor
If execution of the servicetask6 fails, the transaction will be rolled back, leaving the state of the process still in "user task" waiting to be completed…

luisalves00
Champ in-the-making
Champ in-the-making
well…I got it stuck on  servicetask6 (in fact is another path so is a servicetask5)…

so I think the behaviour is this:

<blockcode>
tx.begin()
    servicetask6
tx.commit()

tx.begin()
    servicetask7
    [throw exception…tx.rollback() ]
tx.commit()
</blockcode>

the process is now "blocked"….on the table activiti.act_ru_execution

Act_id_ = servicetask6
is_Active_ = 1
is_Scope_ = 1


So how can I get the process running again?

luisalves00
Champ in-the-making
Champ in-the-making
tks..what a quick answer.

even if I got a following servicetask7? i.e. userTask –>  servicetask6 –> servicetask7 

If servicetask7 fails, I get back to the userTask, right?

(still using engine 5.7)


frederikherema1
Star Contributor
Star Contributor
Is the servicetask7 or servicetask6 marked as async?

luisalves00
Champ in-the-making
Champ in-the-making
No. Using the default settings.

I've tested the code using a break point on the servicetask7 and changing a variable value to get a NPE.
The flow rollbacked to the UserTask, so you must span the transactions (as I expected). 
But something went wrong, at least in 3 cases, where the flow blocked at servicetask6. This makes any sense?
Is there a way to signal the flow to keep going?

tks.

LA

frederikherema1
Star Contributor
Star Contributor
You SHOULD NOT commit transactions manually in between 2 non-async steps (like the service-tasks). This will cause the engine to fail to roll-back to the previous state (== previous wait state before servicetask6). Since the transaction is commited by you after servicetask6, this "trail" is lost forever and it will fail.

To put it simple, NEVER commit transactions during a single API-call!! You can have activiti participate in an external transaction without issues, as long as the transaction spans at least a single API-call.