I have the following scenario
I have to do create multiple instances(count determined by call to DB) of 5 different business processes which are modelled in separate workflows
For illustration naming them
- Workflow 1
- Workflow 2
- Workflow 3
- Workflow 4
- Workflow 5
I will have to start multiple instances of the above workflows based on some data in the database
I will also need a parent workflow(to manage creating the above workflows) which will essentially do the below steps
Note: This workflow should never die, unless stopped externally. I want this workflow as a scheduler to create instances of other workflows. This workflow will be started when the container starts
Step1. Read data from the database using a REST API in a service task.
. The data from step1 will tell the following information
Workflow 1 -> create 5 instances
Workflow 2 -> create 2 instances
Workflow 3 -> create 1 instances
Workflow 4 -> nothing yet to create
Workflow 5 -> nothing yet to create
Note: We have some thresholds set, which ensures not many PI are being created by this process
Step 2: I am trying to start these process instances using the java API of the RuntimeService in the next service task
runtimeService.startProcessInstanceByKey("workflow1");.
* 5 times
runtimeService.startProcessInstanceByKey("workflow2");.
* 2 times
runtimeService.startProcessInstanceByKey("workflow3");.
* 1 time
Not starting workflow 4 and workflow 5 as there is no need in this iteration
I am calling this number of times based on the data in step2
I am expecting that all these process instances will be started async
The purpose of this workflow is only to start the other workflows
Step 3 . After i have finished starting all the process instances for workflow1 to workflow5
I am doing some process cleanup and sending the flow back to Step 1
This keeps going in a loop and does the same steps again
I observed that the execution of the workflows(workflow1 to workflow5) are not triggering at all . until the main workflow is stopped
I have tried different mechanism but unsuccessful in achieving the use case
What is the best approach to model this? I am not sure what has to be done to achieve this.Can someone please help with the same?
I am using the spring boot camunda starter to do the same
I have attached the master workflow which has 3 service tasks
1.Get Data (explained earlier)
2.Schedule Workflow(Start child workflows)
3.Cleanup