Restartable processes refer to business models that are designed in such a way that they can be restarted at any point of their execution without losing or corrupting any data or the model instance status after restart: when restarted, such model instances skip through the activities that were already performed until they reach the status from before the restart. To design such models, you need to make sure that the models rely only on persisted data; the model instance itself must not at any point rely on any data that gets lost when it finishes.
For example, if you interrupt an order-dispatch process at a moment when the order is ready for dispatch, on the restart of the model instance, the process omits the invoicing and payment activities based on the order status and proceeds directly to the dispatch activity.
This design pattern is especially useful when you want to be able to update the underlying models or application. With restartable models you simply
In the sections below you will learn how to:
We start from a simple flow that runs over a piece of business data stored in the process variable. The flow has two User activities which signal that the status of the business data changes or is about to change.
In the todo generated by the User activities the user simply submits their Todo.
At this point, the status of the business data is updated to a new status in the User Task assignment. Like this, the status is preserved, even if the model instance is terminated.
Persist all data relevant to the flow logic: Store it in Shared Records or their fields.
In the example, we must change the type of the order process variable from a common record to a shared record: every model instance runs for a particular order. The status of the order process is determined by the status field of the order variable.
Adapt the way you acquire the business data so that the process gets the correct data when started.
In the example, this means to initialize the order process variable to one of the following:
watchStarting()
on the started model instances. This will activate the monitoring of its start. foreach Order o in findAll(Order) do
def ModelInstance i := createModelInstance(true, getModel("simpleRestartableProcess"), o, null);
watchStarting(i);
end
clearApplicationRestartData()
call before the createModelInstance()
calls: this will remove the data about the previous model-instance starting.watchStarting(thisModelInstance())
after the clearApplicationRestartData()
call on the orchestrating model as well; like this you can check if the starting of this instance was successful. Call the function from, for example, the Start assignment of the process. The location of the call does not really matter, however, it must be called from within the first transaction of the model. This is a very simple process and in more complex processes, the designing of the skipping might become tedious if not impossible. Consider extracting the skippable elements that change the status of your data to separate processes and create a process that will call them in Reusable Subprocess activities. For a full example, refer to the agile pattern.
To test the model: