cancel
Showing results for 
Search instead for 
Did you mean: 

'multi-instance' does not work

othmann
Champ in-the-making
Champ in-the-making
Hi,

  I'm trying to have a mail task repeated several times, in order to send many mails in a loop.

  Here is the BPMN task description :

    <serviceTask id="mailtask1" name="Mail" activiti:type="mail">
      <extensionElements>
        <activiti:field name="to" expression="${invites[loopCounter]}"></activiti:field>
        <activiti:field name="from" expression="xxxxxxxxxxxxxxx"></activiti:field>
        <activiti:field name="subject" expression="XXXXXXXXXXXXXXXX"></activiti:field>
        <activiti:field name="html">
          <activiti:expression><![CDATA[
                    XXXXXXX
           !]]></activiti:expression>
        </activiti:field>
      </extensionElements>
      <multiInstanceLoopCharacteristics isSequential="false">
        <loopCardinality>5</loopCardinality>
    </multiInstanceLoopCharacteristics>
    </serviceTask>

  In this case, the "loopCounter" variable seems not to be known :

Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'loopCounter'

  I've tried the "collection" and "elementVariable" way of doing (which is in fact what I really need), but the variable I chose as "elementVariable" is not known either as a local variable in the process.

   Any help about this would be really appreciated.

  Othman

  PS : It is also very annoying that the Eclipse Designer removes the "multiInstanceLoopCharacteristics" node when we update the process diagram visually. This, however, seems normal.
16 REPLIES 16

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
PS : It is also very annoying that the Eclipse Designer removes the "multiInstanceLoopCharacteristics" node when we update the process diagram visually. This, however, seems normal.

No it is not… please file a jira issue for this

regarding the loopcounter, I have no idea, not experimented with it yet. Someone else needs to respond to this.

othmann
Champ in-the-making
Champ in-the-making
Done for the designer : http://jira.codehaus.org/browse/ACT-758

othmann
Champ in-the-making
Champ in-the-making
Okay, I might get it : it is also due to the eclipse designer. When we build the deployment artifacts, it seems that the generated "process.bpmn20.xml" file does not contain the "multiInstanceLoopCharacteristis" either, as if it was re-processed. Then it is normal that the "loopCounter" variable is unknown.

I added a comment in the issue about that.

othmann
Champ in-the-making
Champ in-the-making
No, it doesn't solve the original issue : the "loopCounter" is still unknown in the task. We have then a double issue about this :

- The Eclipse Designer removes the "multiInstanceLoopCharacteristics"  when saving graphically the process or when building the deployment artifacts.
- The engine seems not take into account the node, with the "loopCounter" variable unrecognized.

jbarrez
Star Contributor
Star Contributor
Mmm, this is tested in our testsuite. Could you create a simple test case that shows the error (eg changing the mail with something that prints out instead)?

othmann
Champ in-the-making
Champ in-the-making
Well, I don't know if this is what you expect from such a test, but :

- I wrote a simple process :
  <process id="testProcess" name="Processus de test">
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="servicetask1" name="Service Task" activiti:class="xxxxxxxx.EchoTask">
      <multiInstanceLoopCharacteristics isSequential="false">
      <loopCardinality>5</loopCardinality>
    </multiInstanceLoopCharacteristics>
    </serviceTask>
    <sequenceFlow id="flow2" name="" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow3" name="" sourceRef="servicetask1" targetRef="endevent1"></sequenceFlow>
  </process>
- The "EchoTask" does nothing but write "Hello !" in the standard output (System.out.println).
- I wrote a simple test case that deploys and starts this process.
- "Hello !" is written only once :
INFO: ProcessEngine default created
5 avr. 2011 12:42:03 org.activiti.engine.ProcessEngines initProcessEnginFromResource
INFO: initialised process engine default
5 avr. 2011 12:42:03 org.activiti.engine.impl.jobexecutor.JobAcquisitionThread run
INFO: JobAcquisitionThread starting to acquire jobs
5 avr. 2011 12:42:03 org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
INFO: Processing resource TestProcess.bpmn20.xml
5 avr. 2011 12:42:03 org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
INFO: XMLSchema currently not supported as typeLanguage
5 avr. 2011 12:42:03 org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
INFO: XPath currently not supported as expressionLanguage
Hello !

  Am I using the "multiInstanceLoopCharacteristics" in the right way ? Shoud I try with a userTask ? Any help would be appreciated.

jbarrez
Star Contributor
Star Contributor
I'll be damned … you are correct.
Really odd - as I'm sure we test automatics in the testsuite…

I've created http://jira.codehaus.org/browse/ACT-764, and start investigating immediately.

othmann
Champ in-the-making
Champ in-the-making
Thanks a lot, let me know if I can help in any way.

jbarrez
Star Contributor
Star Contributor
I've fixed it on trunk. there was indeed a bug that made it impossible to use multi instance on a service task that delegates to a class.
i've enhanced our test suit to cover this case - thank you very much!