Splitting batch with sequential multiple instance

Hi,

I have a process where I receive a batch of products and I want to handle them one by one.

What do I need to specify in the SMI “Split batch” task in order to reproduce N tokens?
In the start event I have a form where I give as input a variable “batchcount”.
That variable I give it to the Loopcardinality field of the SMI as #{batchcount} but it doesn’t work.
Actually, even if I put a random number in the loop cardinality, I don’t get many tokens.

What do I miss?

Thanks!

Take a look at: Pattern Review: DMN Looping for Array Input

You need to be using a sub-process if you want to process the batches with multiple tasks being performed for each item

Edit: can also take a look at: Idiomatic solution for the 1-n problem

1 Like

Thanks @StephenOTT,

I will check it out.

  • But how can I generate many tokens before a series of tasks?
  • If I use a MI subprocess, can this expand in different lanes of a pool? Because my tasks that need to be executed in the MI subprocess are performed by different roles.

Thanks!

@kontrag you need to read the docs and the links i posted above about Multi-Instance Sub-processes.

You can split your batch/collection with the mult-instance features. Your process will look something like this:

Review the links i posted, there are step by step code snippets and even more complex examples using the DMN rules engine.

  • If I use a MI subprocess, can this expand in different lanes of a pool? Because my tasks that need to be executed in the MI subprocess are performed by different roles.

Camunda (currently, at least as of 7.6) does not use Pools to limit task assignment. So the Pools are a visual aspect, not a executable aspect.

If you want to use a pool and have a large sub-process, then you could use a Call-Activity such as:

This will let you call your Multi-Instance sub-process as a external BPMN file and have all of the features without the visual complexity.

2 Likes

Thanks @StephenOTT!

I’m trying out the Call Activity with sequential multi-instance.
What I noticed is that when you update a variable in the lower level of the sub process, then it’s not updated on the same time in the upper level of the call activity until the running instance finishes.
Is there a way to change it?

Thanks!

@kontrag are you running your entire process as a single transaction? (no wait states)
Add a async and see if it updates at the wait state.

Also take a look at this section of the variables docs: https://docs.camunda.org/manual/7.4/user-guide/process-engine/variables/#java-object-api. There is a example and explanation of updating localized variables (not the parent scope) if that is what you are trying to achieve. You can then use the Input/Output mappings of the Call activity to move data around.