cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with multi-instance sub-process

dwoodbury
Champ in-the-making
Champ in-the-making
Hello:

Does the activiti engine support the attached process definition?

I receive the following error when boundary event timers expire within the multi-instance sub-process:

2011-06-29 22:30:32,681 [pool-1-thread-18] ERROR interceptor.CommandContext  - Error while closing command context
org.activiti.engine.ActivitiOptimisticLockingException: ExecutionEntity[113] was updated by another transaction concurrently

The process image is attached.  Here is the bpmn.xml.

<?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:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="TrainingRequest" name="TrainingRequest">
    <documentation>Place documentation for the 'TrainingRequest' process here.</documentation>
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="User Task" activiti:assignee="ROLE_USER">
      <multiInstanceLoopCharacteristics isSequential="false"></multiInstanceLoopCharacteristics>
    </userTask>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <subProcess id="subprocess1" name="Sub Process">
      <multiInstanceLoopCharacteristics isSequential="false">
        <loopCardinality>5</loopCardinality>
      </multiInstanceLoopCharacteristics>
      <userTask id="subprocess1usertask2" name="User Task" activiti:assignee="ROLE_USER"></userTask>
      <boundaryEvent id="subprocess1boundarytimer1" name="" cancelActivity="true" attachedToRef="subprocess1usertask2">
        <timerEventDefinition>
          <timeDuration>PT1M</timeDuration>
        </timerEventDefinition>
      </boundaryEvent>
      <serviceTask id="subprocess1mailtask1" name="Mail Task" activiti:type="mail">
        <extensionElements>
          <activiti:field name="to" expression="[email protected]"></activiti:field>
          <activiti:field name="from" expression="[email protected]"></activiti:field>
          <activiti:field name="subject" expression="test"></activiti:field>
          <activiti:field name="html">
            <activiti:expression><![CDATA[test]]></activiti:expression>
          </activiti:field>
        </extensionElements>
      </serviceTask>
      <sequenceFlow id="subprocess1flow3" name="" sourceRef="subprocess1boundarytimer1" targetRef="subprocess1mailtask1"></sequenceFlow>
      <endEvent id="subprocess1endevent2" name="End"></endEvent>
      <sequenceFlow id="subprocess1flow5" name="" sourceRef="subprocess1mailtask1" targetRef="subprocess1endevent2"></sequenceFlow>
      <sequenceFlow id="subprocess1flow6" name="" sourceRef="subprocess1usertask2" targetRef="subprocess1endevent2"></sequenceFlow>
      <startEvent id="subprocess1startevent2" name="Start"></startEvent>
      <sequenceFlow id="subprocess1flow7" name="" sourceRef="subprocess1startevent2" targetRef="subprocess1usertask2"></sequenceFlow>
    </subProcess>
    <sequenceFlow id="flow2" name="" sourceRef="usertask1" targetRef="subprocess1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow4" name="" sourceRef="subprocess1" targetRef="endevent1"></sequenceFlow>
  </process>
</definitions>

Thank you for your help

David Woodbury
5 REPLIES 5

jbarrez
Star Contributor
Star Contributor
That should just work.

Can you put the failing process in a unit test and create a new jira?

dwoodbury
Champ in-the-making
Champ in-the-making
I've not done that before, but I can try.  Can you point me to some instructions or examples?  I checked the forums but didn't find a thread for newbies with respect to development.

Also, is it a fair assumption on my part that this is likely an issue with the engine?  The sub-process runs autonomously in the engine, creating 5 user-tasks, each with a cancel timer.  When the timers expire, the engine throws a concurrency exception.

The reason I ask is because I'm thinking the issue has to due with the non-uniqueness of the task and/or timer id. 

I thought I could work-around this issue by giving each user-task a unique name, but I couldn't determine how to parameterize the task and timer names with the loopCounter variable. (or other expression)

Is there a way to define the sub-process such that the embedded timer and user tasks are assigned unique ID's?

Thanks again.

jbarrez
Star Contributor
Star Contributor
I've not done that before, but I can try. Can you point me to some instructions or examples? I checked the forums but didn't find a thread for newbies with respect to development.

The examples shipped with the Activiti distribution are all Junit test. So best place to start there

Also, is it a fair assumption on my part that this is likely an issue with the engine? The sub-process runs autonomously in the engine, creating 5 user-tasks, each with a cancel timer. When the timers expire, the engine throws a concurrency exception.

It sure is possible that it is a bug, but that must be confirmed by a failing test case.

Is there a way to define the sub-process such that the embedded timer and user tasks are assigned unique ID's?
Don't worry, all entities in Activiti get a unique (internal) id. So that's unlikely going the be the issue.

dwoodbury
Champ in-the-making
Champ in-the-making
Thanks for the help.  I created a test case for the above process definition and was able to reproduce the exception. The exception occurs when the task following the boundary event timer is a mail service task.  If the following task is a user task, no exception is raised.

The JIRA ticket is ACT-901 at the following link:

http://jira.codehaus.org/browse/ACT-901

jbarrez
Star Contributor
Star Contributor
Thanks!