This chapter describes the usage of a variant HALT of spawn option for the
WorkflowService
method spawnPeerProcessInstance(long processInstanceOid, String spawnProcessID, SpawnOptions options):
/**
* Creates a new SpawnOption that allows to specify the starting activity and detailed data copy options.
*
* @param startActivity the activity from which the spawned process instance should start.
* If null, the spawned process instance will start from the default start activity.
* @param spawnMode specifies what action to take with the originating process instance. {@link SpawnMode#Keep}, {@link SpawnMode#ABORT} or {@link SpawnMode#HALT}.
* @param comment a comment describing the operation. May be null.
* @param dataCopyOptions instructions on how the data should be transferred from the
* originating process instance to the spawned process instance. If null, then
* {@link DataCopyOptions.DEFAULT} is used.
*/
public SpawnOptions(String startActivity, SpawnMode spawnMode, String comment,
DataCopyOptions dataCopyOptions)
Using this option, you can set the SpawnMode to HALT.
In this state, no transition is allowed via the
WorkflowService
API until the process is resumed. In this case, the behavior would be as follows:
PredefinedProcessInstanceLinkTypes#INSERTTo specify the spawn mode, use the following enum constant:
public enum SpawnMode
{
KEEP,
ABORT,
HALT
}
For more information, please refer to the JavaDoc of the SpawnOptions class.
The following example code demonstrates how to use the spawn option HALT.
We spawn to a process with ID targetProcessId in model ProcessModel from a
process instance orgProcessInstance. The options parameter comprises the
following options:
HALT, to determine that the originating process instance
(orgProcessInstance) should be halted
DataCopyOptions dataCopyOptions = new DataCopyOptions(true, null, null, true);
ProcessInstance pi;
SpawnOptions options;
options = new SpawnOptions(null, SpawnMode.HALT, linkComment, dataCopyOptions);
pi = ServiceFactoryUtils.getWorkflowService().spawnPeerProcessInstance(orgProcessInstance.getOID(),
{ProcessModel}targetProcessId, options);
Note that we use the fully qualified process id for targetProcessId to make sure the process is spawned in the correct model version.
Completion of a process checks for a PredefinedProcessInstanceLinkTypes#INSERT
link and starts a resume on the linked source process. The linked source process is resumed if all of its linked target processes
are already terminated.
Note that when using the API to halt a process, you may get a ConcurrencyException.
In that case, wait for some time and retry the API call.