Workflow Processing for Spawn Subprocess

This chapter describes the usage of Infinity Process Platform APIs concerning spawnable processes:

Workflow Service Methods

Spawning a Process

The Workflow Service method spawnSubprocessInstance spawns a process as subprocess of the specified process instance.

 /**
    * Spawns a process as subprocess of the specified process instance. The spawned
    * process executes asynchronously but has to be completed before the parent process is
    * able to complete.
    *
    * @param parentProcessInstanceOID The oid of the process to spawn from.
    * @param spawnProcessID The id of the process definition to spawn as a subprocess.
    * @param copyData Defines if data of the parent process definition should be copied to the spawned process.
    * @param data Contains data IDs as key set and corresponding data values to be set
    *        as values.
    *
    * @return the {@link ProcessInstance} that was spawned.
    */
   ProcessInstance spawnSubprocessInstance(long parentProcessInstanceOID,
         String spawnProcessID, boolean copyData, Map<String, ?> data);

The required permission to execute this method is spawnSubProcessInstance.

Spawning Multiple Processes

To spawn multiple processes as subprocesses of the specified process instance, use spawnSubprocessInstances method.

/**
    * Spawns multiple processes as subprocesses of the specified process instance. The spawned
    * processes execute asynchronously but have to be completed before the parent process is
    * able to complete.
    *
    * @param parentProcessInstanceOID The oid of the process to spawn from.
    * @param subprocessSpawnInfo A List of {@link SubprocessSpawnInfo} holding information about the subprocesses to be spawned.
    * @return A list of {@link ProcessInstance} that were spawned.
    */
   List<ProcessInstance> spawnSubprocessInstances(long parentProcessInstanceOID, List<SubprocessSpawnInfo> subprocessSpawnInfo);

Retrieving Information of Spawned Processes

The SubprocessSpawnInfo method is used to retrieve the information of spawned processes.

/**
    * @param processId The process id.
    * @param copyData Specifies if data of the parent process instance should be copied.
    * @param data Allows specifying explicit data values which are set instead of copied.
    */
   public SubprocessSpawnInfo(String processId, boolean copyData, Map<String, ? > data)

Aborting Spawned Process

A spawned subprocess can be aborted by following methods:

Recovering Spawned Process

Recovery of spawned process is similar to synchronously started subprocesses. To recover spawned process, use following methods:

Query Service Methods

The semantic of existing APIs is not changed for spawned processes but their scope is increased to include the spawn process as a subprocess.

Use following methods of ProcessInstanceQuery class:

Querying Spawnable Processes

The user is allowed to start spawnable processes as they are manual processes. They are limited to processes of the same model and started in the scope of an active process instance. The ProcessDefinitionQuery retrieves the manual startable processes from a specific model. The findStartable method returns the processes that have manual triggers assigned.

 /**
    * Creates a query for finding manually startable processes contained in a specific model.
    *
    * @param modelOID specifies the model to retrieve manually startable processes from.
    * @return The configured query.
    *
    */
   public static ProcessDefinitionQuery findStartable(long modelOID)

Note that when using the API to spawn a subprocess, you may get ConcurrencyException. In that case, wait for sometime and retry the API call.