---
schema_version: "1"
id: e323963cf186c9405ad3517eed7ce5463313d40770831c58b11374a294bc235b
title: EventPublishFailureCallback Interface
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_interface_eventbus_EventPublishFailureCallback.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_eventbus_EventPublishFailureCallback.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: b5377bd6348a3ea16ced9741514fe2d7c141e9e583243e3398aa4ed5fc2fc548
description: Implement this interface to track platform event messages that failed to publish. The onFailure() method in this interface is called when the final result of the asynchronous publish operation becomes available. The system invokes this method when the final result of EventBus.publish is available and the publishing of the platform event message failed.
---
# EventPublishFailureCallback Interface

Implement this interface to track platform event messages that failed to publish. The onFailure() method in this interface is called when the final result of the asynchronous publish operation becomes available.

## Namespace

[EventBus](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_eventbus.htm "The EventBus namespace provides classes and methods for platform events and Change Data Capture events.")

## Usage

For more information, see [Get the Result of Asynchronous Platform Event Publishing with Apex Publish Callbacks](https://developer.salesforce.com/docs/atlas.en-us.264.0.platform_events.meta/platform_events/platform_events_publish_callbacks.htm) in the Platform Events Developer Guide.

- **[EventPublishFailureCallback Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_eventbus_EventPublishFailureCallback.htm#apex_eventbus_EventPublishFailureCallback_methods)**
- **[EventPublishFailureCallback Example Implementation](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_eventbus_EventPublishFailureCallback.htm#apex_interface_eventbus_EventPublishFailureCallback_Example)**

## EventPublishFailureCallback Methods

The following are methods for EventPublishFailureCallback.

- **[onFailure(result)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_eventbus_EventPublishFailureCallback.htm#apex_eventbus_EventPublishFailureCallback_onFailure)**  
    The system invokes this method when the final result of EventBus.publish is available and the publishing of the platform event message failed.

### onFailure(result)

The system invokes this method when the final result of EventBus.publish is available and the publishing of the platform event message failed.

#### Signature

public void onFailure(eventbus.FailureResult result)

#### Parameters

- **result**:
    
    Type: [EventBus.FailureResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_eventbus_FailureResult.htm#apex_interface_eventbus_FailureResult "Contains the result of an Apex publish callback when the event publishing failed. This interface is used as a parameter in the onFailure method of the EventPublishFailureCallback interface.")
    
    The final result of EventBus.publish.

#### Return Value

Type: void

## EventPublishFailureCallback Example Implementation

For an example implementation and a test class, see [Get the Result of Asynchronous Platform Event Publishing with Apex Publish Callbacks](https://developer.salesforce.com/docs/atlas.en-us.264.0.platform_events.meta/platform_events/platform_events_publish_callbacks.htm) in the Platform Events Developer Guide.