cancel
Showing results for 
Search instead for 
Did you mean: 

New to Activiti: Question about multi instance activity

elkammar
Champ in-the-making
Champ in-the-making
Hi,

We are running few POC's to evaluate if we can use Activiti for our automation framework. So far I like it, however, I just have difficulties understanding how does Activiti handles the multi-instance activity in parallel, so far it appears to be doing that on the same thread, is that normal or am I missing something here?

What I have done is a very simple workflow, that has a call-activity, that has a specific number for its "loop cardinality" parameter, and I set "sequential" to false. I was expecting all instance threads to start around the same time and run in parallel, but what I saw is that they use the same thread and they start sequentially.

I use activity engine version 5.17.0, I have set the "asyncExecutorEnabled" and "asyncExecutorActivate" to true, and disabled "jobExecutorActivate", I tested this scenario on the Activiti explorer.

I apologize if I am missing something obvious as I just started using it to see how it fits in our architecture.

Thank you!
6 REPLIES 6

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Abdullah,

try make the first multiinstance task asynchronous.
In that case multiinstnace will create n jobs sequentially and jobs are executed in parallel.

Regards
Martin

elkammar
Champ in-the-making
Champ in-the-making
Thanks, Martin!
That helped and seem to work, the engine consumes the tasks in parallel now and it takes two at a time and then it throws this:
<blockcode>ERROR org.activiti.engine.impl.cmd.JobRetryCmd  - activitiy or FailedJobRetryTimerCycleValue is null in job 91'. only decrementing retries.</blockcode>

Does that mean it was pulling and found nothing int he queue or does it mean my task was failed and it was retrying it?
FYI, I am just testing using <java>Thread.sleep();</java>, but I wanted to understand how it works under the covers, I understand from the user guide that <java>AsyncExecutor</java> manages a thread pool but I am trying to understand how it works a bit more, for instance, if the engine executes two tasks in parallel at a time then can this(or the size of the thread pool) be configured?

Appreciate your help!

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Abdullah,

could you create jUnit test for it (http://forums.activiti.org/content/sticky-how-write-unit-test). It is hard to guess when I do not see it.

Regards
Martin

elkammar
Champ in-the-making
Champ in-the-making
I posted my test class and bpmn files here yesterday, but I think it's going through some approval process..?

elkammar
Champ in-the-making
Champ in-the-making
Ok here it is again in case my previous comment was lost somehow:
My test case:
<java>
@Test
@Deployment(resources = {"org/activiti/test/main-process.bpmn"
   , "org/activiti/test/call-activity-process.bpmn"})
public void test() {
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("main-process");
     waitForJobExecutorToProcessAllJobs(100000L, 100);
  assertNotNull(processInstance);
}
</java>

main-process.bpmn
<code>
<?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="http://www.activiti.org/test">
  <process id="main-process" isExecutable="true">
    <startEvent id="start"></startEvent>
    <callActivity id="callactivity1" name="Call activity" calledElement="subprocess">
      <multiInstanceLoopCharacteristics isSequential="false">
        <loopCardinality>5</loopCardinality>
      </multiInstanceLoopCharacteristics>
    </callActivity>
    <sequenceFlow id="flow1" sourceRef="start" targetRef="callactivity1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow2" sourceRef="callactivity1" targetRef="endevent1"></sequenceFlow>
  </process>

</definitions>
</code>

call-activity-process.bpmn:
<code>
<?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="http://www.activiti.org/test">
  <process id="subprocess" name="Sub" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="servicetask1" name="Service Task" activiti:async="true" activiti:exclusive="false" activiti:class="org.activiti.delegates.ServiceTask"></serviceTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow1" sourceRef="servicetask1" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
  </process>
 
</definitions>
</code>

And my JavaDelegate subclass has just <java>Thread.sleep(5000)</java> in it.
The jUnit test will pass, but it will produce the below error multiple times which I am trying to understand what am I missing here.
ERROR org.activiti.engine.impl.cmd.JobRetryCmd  - activitiy or FailedJobRetryTimerCycleValue is null in job 91'. only decrementing retries.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

https://github.com/martin-grofcik/activiti-unit-test-template/tree/abdullah

The log message is written when is no activity or FailedJobRetryTimeCycleValue set.


    if (activity == null || activity.getFailedJobRetryTimeCycleValue() == null) {
      log.error("activitiy or FailedJobRetryTimerCycleValue is null in job " + jobId + "'. only decrementing retries.");


Regards
Martin