TaskOrchestrationContext.ContinueAsNew(Object, Boolean) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Restarts the orchestration with a new input and clears its history.
public abstract void ContinueAsNew (object? newInput = default, bool preserveUnprocessedEvents = true);
abstract member ContinueAsNew : obj * bool -> unit
Public MustOverride Sub ContinueAsNew (Optional newInput As Object = Nothing, Optional preserveUnprocessedEvents As Boolean = true)
Parameters
- newInput
- Object
The JSON-serializable input data to re-initialize the instance with.
- preserveUnprocessedEvents
- Boolean
If set to true
, re-adds any unprocessed external events into the new execution
history when the orchestration instance restarts. If false
, any unprocessed
external events will be discarded when the orchestration instance restarts.
Remarks
This method is primarily designed for eternal orchestrations, which are orchestrations that may not ever complete. It works by restarting the orchestration, providing it with a new input, and truncating the existing orchestration history. It allows an orchestration to continue running indefinitely without having its history grow unbounded. The benefits of periodically truncating history include decreased memory usage, decreased storage volumes, and shorter orchestrator replays when rebuilding state.
The results of any incomplete tasks will be discarded when an orchestrator calls ContinueAsNew(Object, Boolean). For example, if a timer is scheduled and then ContinueAsNew(Object, Boolean) is called before the timer fires, the timer event will be discarded. The only exception to this is external events. By default, if an external event is received by an orchestration but not yet processed, the event is saved in the orchestration state unit it is received by a call to WaitForExternalEvent<T>(String, CancellationToken). These events will continue to remain in memory even after an orchestrator restarts using ContinueAsNew(Object, Boolean). You can disable this behavior and remove any saved external events by specifying false
for the preserveUnprocessedEvents
parameter value.
Orchestrator implementations should complete immediately after calling the ContinueAsNew(Object, Boolean) method.