---
schema_version: "1"
id: e17438fc5668d6cdba9dde583ae3ed0acb6b76794aec3e4a6d16d2013c07bff0
title: Finalizer Interface
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_interface_System_Finalizer.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_System_Finalizer.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 2f44da5ec1584236533aee8bf029a97b413ad53a737e6dc5ab1b59d7907925a7
description: 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.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.
---
# 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](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_System.htm "The System namespace provides classes and methods for core Apex functionality.")

## 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](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_System_Finalizer.htm#apex_System_Finalizer_methods)**
- **[Finalizer Example Implementation](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_System_Finalizer.htm#apex_interface_System_Finalizer_Example)**

## Finalizer Methods

The following are methods for Finalizer.

- **[execute(finalizerContext)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_System_Finalizer.htm#apex_System_Finalizer_execute)**  
    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.

### 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

- **finalizerContext**: Type: [FinalizerContext Interface](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_System_FinalizerContext.htm#apex_interface_System_FinalizerContext "Represents the parameter type of the execute method in a class that implements the Finalizer interface. This interface is implemented internally by Apex. The System.FinalizerContext interface contains four methods: getAsyncApexJobId, getRequestId, getResult, and getException. An instance of System.FinalizerContext is injected by the Apex runtime engine as an argument to the Finalizer.execute method.")

#### Return Value

Type: void

## Finalizer Example Implementation

For a sample implementation of the System.Finalizer interface, see the Logging Finalizer Example in [Transaction Finalizers](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/apex_transaction_finalizers.htm).