Why and when to perform this task
Sometimes, it
is necessary for someone with process administrator authorization to terminate
a top-level process instance that is known to be in an unrecoverable state.
For example, when an application is invoked and fails, and it does not return
to a dormant state.
Because a process instance terminates immediately,
without waiting for any outstanding subprocesses or activities, you should
terminate a process instance only in exceptional situations.
Steps for this task
- Retrieve the process instance that is to be terminated.
ProcessInstanceData processInstance =
process.getProcessInstance("CustomerOrder");
- Terminate the process instance.
If you terminate
a process instance, you can terminate the process instance with or without
compensation.
To terminate the process instance with compensation:
PIID piid = processInstance.getID();
process.forceTerminate(piid, CompensationBehaviour.INVOKE_COMPENSATION);
To
terminate the process instance without compensation:
PIID piid = processInstance.getID();
process.forceTerminate(piid);
If you
terminate the process instance with compensation, the compensation handler
defined for the process template is called. If the process template does not
have a compensation handler defined, the default compensation handler is called.
If you terminated the process instance without compensation, the process instance
is terminated immediately without waiting for activities to end normally.
Applications
that are started by the process are not affected by the force terminate request.
If these applications are to be terminated, you must add statements to your
process application that explicitly terminate the applications started by
the process.