How to start a subprocess in activiti?

To start a sub-process in Activiti, you need to use the “callActivity” type of activity element. Below are the steps for starting a sub-process in Activiti:

  1. Create a new subprocess definition: In Activiti, a subprocess is a separately defined process that can be reused within the main process. Create a subprocess definition using Activiti’s designer or programmatically.
  2. Add a “callActivity” activity element to the main process: In the BPMN diagram of the main process, include a “callActivity” activity element to initiate a sub-process. In the properties panel, specify the name of the sub-process definition or reference the key of the sub-process definition.
  3. Configure the input parameters of “callActivity”: In the properties panel, set up the input parameters of “callActivity” to pass variables from the main process to the sub process.
  4. Configure the output parameters of “callActivity”: In the Properties panel, set the output parameters of “callActivity” to pass variables from the subprocess to the main process.
  5. Deployment and execution process: Deploy the main process and sub-process together into the Activiti engine, then start the main process instance. When the main process reaches the “callActivity” task, it will automatically create and start a sub-process instance.
  6. After the subprocess is completed, it returns to the main process which receives the output parameters from the subprocess and can continue with subsequent activities.

Important points to note:

  1. Parameters can be passed between sub processes and main processes, allowing for the use of variables from the main process within the sub process, and for the passing of results from the sub process to the main process.
  2. The execution of the sub-process and the main process is independent, as they each have their own process instances and execution environments.
  3. Subprocess can include other elements such as user tasks, service tasks, etc.
  4. The definition of a sub-process can be done within the same BPMN file or in different files. If in different files, the key of the sub-process needs to be referenced in the main process.
  5. Activiti supports nested subprocesses, allowing subprocesses to be nested within other subprocesses.

I hope the above information is helpful for you!

bannerAds