Monitoring the start of model instances allows you to check if a model instance has successfully finished its start sequence, which is by default the first model transaction.
Monitoring the start of model instances is typically useful when starting restartable model instances. Restartable model instances are based on a pattern that makes sure that a model instance returns to the correct status after if finished prematurely.
Such models rely on persisted business data for their status: If a piece of business data has been already handled by the given flow element or has been otherwise processed so that the element does not need to be executed, the element is skipped. More details on the pattern are available in the tutorial on restartable models:
When finishing and subsequently starting restartable model instances with the monitoring mechanism in place, you can check when and if the model instances have reached the status they were in before restart: You can start and check the status of the model instances manually, however, it is recommended to design an orchestrating model that will start and monitor the starting of model instances over your business data.
To implement the monitoring of model instance starting:
clearApplicationRestartData()
to clear the data from a previous start-monitoring run and watchStarting(thisModelInstance())
, for example, from the Start assignment of the process.watchStarting(<ModelInstanceToFollow>)
: At this point, the starting status of the model instance will be set to IN_PROGRESS
. FINISHED
. To finish the start sequence later, define the point when to finish manually.To define, when the starting of a model instance finishes explicitly do the following:
watchStarting()
call, call explicitFinishing()
to prevent the watching from finishing after the first model transaction.modelInstanceStartSucceeded()
call.With the explicitFinishing()
in place, the starting status of the model instance will be IN_PROGRESS_EXPLICIT_FINISH
.
You can define the number of expected model instances that finish their Start with the setCountOfModelInstacesToStart()
call: the number is displayed in the Application restart views.
You can follow the status of starting of model instances in the Restart Application view in Management Console or in the Management perspective. Also, you can use the getStartStatus(ModelInstance modelIntance)
and getStartStatuses(List<ModelInstance> listOfModelIntances)
and getRestartInfo()
functions of the Standard Library or the Command Line tool with the appRestartInfo
and appRestartInfoExport
commands.
If the status of a monitored model instance is FAILED
, the start sequence of the model instance failed with an unhandled exception.
Note that the orchestrating model instance might fail as well: this will depend on whether the exception occurred within its start sequence.