Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

Finalizer Interface

Use this interface to attach actions that are executed at the end of asynchronous Queueable job executions. A specific use case is to design recovery actions when a Queueable job fails.

Namespace

System

Usage

The execute method is called on the provided Finalizer instance for every enqueued job that has an attached finalizer. Within the execute method, you can define the actions to be taken at the end of the Queueable job. An instance of System.FinalizerContext is injected by the Apex runtime engine as an argument to the execute method.

Finalizer Methods

The following are methods for Finalizer.

execute(finalizerContext)

The execute method is called on the provided Finalizer instance for every enqueued job that has an attached finalizer. Within the execute method, you can define the actions to be taken at the end of the Queueable job.

Signature

public void execute(System.FinalizerContext finalizerContext)

Parameters

Return Value

Type: void

Finalizer Example Implementation

For a sample implementation of the System.Finalizer interface, see the Logging Finalizer Example in Transaction Finalizers.