cancel
Showing results for 
Search instead for 
Did you mean: 

Multi instance, add more element at runtime

edgarjoao
Champ in-the-making
Champ in-the-making
Hi team,
I have a muti instance "Call Activity", I was wondering if its possible to add more instances to the current activity?

Regards
17 REPLIES 17

edgarjoao
Champ in-the-making
Champ in-the-making
Thanks for the advice, do you have some example of how to do it?
Edgar

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Edgar,

From my point of view there are plenty of examples.
Basicly what you have to do is to take the logic from e.g. Multiinstance parallel activity behavior to your new command.

Regards
Martin

edgarjoao
Champ in-the-making
Champ in-the-making
It is possible use MultiInstanceLoopCharacteristics for this?

edgarjoao
Champ in-the-making
Champ in-the-making
I did some modifications to my current Multi-Instance adding a boundarymessage and I realize that every time that I was sending a message it was creating a new execution instead to add more instances to current one, I didn't found the way to add more instances Smiley Sad

edgarjoao
Champ in-the-making
Champ in-the-making
Once you call 6 times boundarymessage and you complete embedded subprocess, it will create 6 instances of "Procesar Notificación" this behavior its correct? I added a image diagram of this.

Thanks Edgar

iam
Champ in-the-making
Champ in-the-making
I've added method addInstances to ParallelMultiInstanceBehavior and it works.
I've modified createInstances loop to retrieve nrOfInstances for each loop step:
[java]
nrOfInstances = (Integer) execution.getVariableLocal(NUMBER_OF_INSTANCES);
[/java]

And when I need it I just call addInstances for parent (scope) execution:
[java]
  // executionEntity is a "ConcurrentExecution"
  int additionalNrOfInstances = 5; // I want to add 5 more executions
  ExecutionEntity parentExecution = executionEntity.getParent();
  if (parentExecution.getActivity().getActivityBehavior() instanceof ParallelMultiInstanceBehavior) {
    ParallelMultiInstanceBehavior behavior = ((ParallelMultiInstanceBehavior)parentExecution.getActivity().getActivityBehavior();
    behavior.addInstances(parentExecution, additionalNrOfInstances);
  }
[/java]

iam
Champ in-the-making
Champ in-the-making
Hmm. It does not work for sub processes because of AtomicOperationAtivityEnd removes execution on eventNotificationsCompleted:
[java]execution.remove();[/java]
and after that execution.getExecutions() returns returns array without one element. Therefore ParallelMultiInstanceBehavior should have more complicated logic that I did.

edgarjoao
Champ in-the-making
Champ in-the-making
Thanks iam, but seems like there isn't way to accomplish this Smiley Sad

Edgar