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

dzj
Champ in-the-making
Champ in-the-making
good question!!!

edgarjoao
Champ in-the-making
Champ in-the-making
Seems like that option won't work. I found a comment in the Activiti Book

Implementing the BPMN 2.0 multi-instance activity, pag 247

"The loop cardinality value is processed only once, when the multiinstance
activity is created. When the process variable value changes during
the multi-instance activity execution, this doesn’t result in another number of
instances."

Edgar

edgarjoao
Champ in-the-making
Champ in-the-making
it's this possible to add this feature?

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

From my point of view it is not so big deal to implement this feature.
You can do it by yourselves. Just have a look on org.activiti.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior#createInstances org.activiti.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior#createInstances
Regards
Martin

edgarjoao
Champ in-the-making
Champ in-the-making
Thanks Martin,
Just wonder what would be the way to accomplish this?

- Extending AbstractBpmnParseHandler<CallActivity> or
- Implementing BpmnParseHandler

After that, what would be the way to add a new instance, through Process Variables??

Edgar

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

I would expect that you want to add instances to the currently running multiinstance activity.
In that case I would implement new method to add executions to the currently running multiinstance execution (in parallel case). You can do it in the same way as Parallel Behavior is doing.

Regards
Martin

edgarjoao
Champ in-the-making
Champ in-the-making
Hi Martin,
I tried to follow your recommendation, I made a CustomInstanceBehavior and CustomCallActivityParseHandler

<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
<property name="databaseSchemaUpdate" value="true"/> 
<property name="postBpmnParseHandlers">
  <list>
   <bean class="com.demo.listeners.CustomCallActivityParseHandler" />
  </list>
</property>
</bean>


You are right I just want to add more executions not matter whether my initial list of elements was 5, just to say something more and more depending of the user.

In this case how can I call createInstances and then adding more executions?

Thanks,
Edgar

edgarjoao
Champ in-the-making
Champ in-the-making
I don't know if I'm complicating at all, but is there a way to acomplish this using
Messages boundary event and Messages Catching event?
Just send any quantity of Messages to the subprocess and then wait for termination

Edgar

martin_grofcik
Confirmed Champ
Confirmed Champ
Events -> Yes that's another possibility

behaviour implementation -> You do not need to make changes in the behaviour. What you have to do is to implement command which will create and add new executions to the multiinstance task execution.

Regards
Martin