SK SKYVVA Documentation

Outbound Batch Apex Retry

Overview

Batch Apex Retry is used for outbound processing executed through invokeCalloutV3() in BATCH mode.

In this use case, outbound processing is started manually from the Salesforce Developer Console by using Execute Anonymous. SKYVVA collects the selected Salesforce record IDs and starts outbound processing with Batch Apex.

The initial processing package is based on the Transfer Package Size configured on the outbound Interface.

If the Transfer Package Size is large and the processing requires more Salesforce resources than are available, the Batch Apex execution can reach a supported Salesforce governor limit, such as the Apex heap-size limit.

If a supported governor limit occurs during Batch Apex processing, SKYVVA uses Salesforce BatchApexErrorEvent to detect the failed processing and retry it with a smaller processing size.

This feature helps prevent supported Batch Apex governor-limit failures from leaving outbound records unprocessed without an automatic recovery attempt.

image

Scope

This document covers:

Important: This document describes execution from the Developer Console. The execution mode used in this example is BATCH.

Prerequisites

Before executing the outbound process, make sure that:

  1. The SKYVVA Integration is configured.
  2. The outbound Interface is configured.
  3. The Interface uses Interface API Version V3.
  4. The outbound adapter/target connection is configured correctly.
  5. Salesforce records are available for outbound processing.
  6. Transfer Package Size is configured on the outbound Interface.
  7. The Automated Process user has a valid SKYVVA license key.

Why Does the Automated Process User Need a SKYVVA License?

The Automated Process user is important for Outbound Batch Apex Retry because retry processing is triggered by Salesforce's standard BatchApexErrorEvent.

The user who manually starts invokeCalloutV3() from the Developer Console and the user context that handles the automatic retry are not the same.

Normal Outbound Execution

The initial outbound processing is manually started from the Salesforce Developer Console.

The user opens Execute Anonymous and executes invokeCalloutV3() using:

Mode = BATCH

The initial processing flow is:

Salesforce User
      |
      v
Developer Console
      |
      v
Execute Anonymous
      |
      v
invokeCalloutV3()
      |
      | Mode = BATCH
      v
Outbound Batch Apex

At this point, the Automated Process user is not the user manually starting invokeCalloutV3().

When Is the Automated Process User Used?

The Automated Process user becomes important when Batch Apex processing fails with a supported error.

For example:

Outbound Batch Apex
        |
        v
Prepare Outbound Payload
        |
        X
Supported Governor Limit
        |
        v
Batch Apex Failed

For a supported Batch Apex failure, Salesforce publishes:

BatchApexErrorEvent

The event is handled by a platform event subscriber that runs under the Salesforce Automated Process user.

Batch Apex Failed
        |
        v
BatchApexErrorEvent
        |
        v
Platform Event Subscriber
        |
        v
Automated Process User
        |
        v
SKYVVA Retry Processing

Therefore, automatic SKYVVA retry processing is executed in the context of the Automated Process user.

Why Is a SKYVVA License Required?

After BatchApexErrorEvent is received, SKYVVA needs to execute its processing logic to recover the failed outbound processing.

The retry flow includes:

BatchApexErrorEvent
        |
        v
Automated Process User
        |
        v
SKYVVA Error Handling
        |
        v
Identify Failed Processing
        |
        v
Reduce Processing Size
        |
        v
Start New Batch Apex Job
        |
        v
Retry Outbound Processing

Because this SKYVVA processing is triggered in the context of the Automated Process user, the Automated Process user must have a valid SKYVVA license key.

What Happens If the Automated Process User Has No SKYVVA License?

Salesforce may still publish BatchApexErrorEvent, but the SKYVVA processing triggered by the event may not complete correctly.

Batch Apex Failed
        |
        v
BatchApexErrorEvent
        |
        v
Automated Process User
        |
        X
No SKYVVA License
        |
        v
Retry Processing
May Not Complete Correctly

During testing, a case was observed where:

Therefore, receiving BatchApexErrorEvent alone does not guarantee that the SKYVVA retry processing can complete.

A valid SKYVVA license key must be assigned to the Automated Process user.

Initial Execution vs. Retry Execution

ProcessingUser ContextPurpose
Initial executionSalesforce userManually executes invokeCalloutV3()
Initial Batch ApexStarted by invokeCalloutV3()Processes outbound records
Error eventSalesforcePublishes BatchApexErrorEvent
Retry event handlingAutomated Process userExecutes SKYVVA retry handling
Retry Batch ApexSKYVVA retry processingProcesses failed work again using a smaller size
Important: The Automated Process user is required for the retry processing triggered by BatchApexErrorEvent. It is not the user that manually executes invokeCalloutV3() from the Developer Console.

The key relationship is:

Supported Governor Limit
          |
          v
Batch Apex Failed
          |
          v
BatchApexErrorEvent
          |
          v
Automated Process User
          |
          | Requires
          v
Valid SKYVVA License
          |
          v
SKYVVA Retry Processing

Outbound Processing

- Configure Transfer Package Size

Before executing the outbound process, open the outbound Interface and configure:

Transfer Package Size

The Transfer Package Size defines the initial number of records included in the outbound processing package.

For example:

Outbound Interface
        |
        v
Transfer Package Size = 1000
        |
        v
Outbound Batch Processing

A larger Transfer Package Size allows more records to be processed together.

However, a larger processing package can also require more Salesforce resources for operations such as:

For example:

Large Transfer Package Size
          |
          v
More Records per Package
          |
          v
More Data to Process
          |
          v
Higher Resource Usage
          |
          v
Possible Governor Limit

For example, a large processing package may consume too much Apex heap memory while SKYVVA is preparing the outbound payload.

This is where Batch Apex Retry becomes important.

If the processing reaches a supported governor limit and Salesforce publishes BatchApexErrorEvent, SKYVVA can retry the affected processing using a smaller processing size.

Important: SKYVVA does not permanently modify the Transfer Package Size configured on the Interface. A smaller size is used for retry processing only.

- Open Salesforce Developer Console

Log in to Salesforce and open:

Setup / User Menu → Developer Console

The Developer Console is used to manually start the outbound processing.


- Open Execute Anonymous

From the Developer Console, select:

Debug → Open Execute Anonymous Window

The Enter Apex Code window is displayed.


- Create CallOutControl

Create a CallOutControl object.

skyvvasolutions.CallOutControl c =
    new skyvvasolutions.CallOutControl();

c.returnxml = true;
c.returnListRecord = true;
c.iscreatemessage = true;

The CallOutControl object defines options used during the outbound callout processing.


- Collect the Salesforce Record IDs

Create a list and add the IDs of the records that should be processed.

Example using Account records:

List<String> lId = new List<String>();

for (Account a : [SELECT Id FROM Account]) {
    lId.add(a.Id);
}

In this example, the Account IDs are collected and passed to invokeCalloutV3() for outbound processing.

You can change the SOQL query when you want to process only specific records.

For example:

SELECT Id
FROM Account
WHERE Name LIKE 'Batch Retry Test%'

- Execute invokeCalloutV3() in BATCH Mode

Call invokeCalloutV3() and specify BATCH as the execution mode.

skyvvasolutions.IServices.invokeCalloutV3(
    'Callout_Integration',
    'Account_Bat_Out-V3',
    lId,
    'BATCH',
    c
);

Example complete code:

skyvvasolutions.CallOutControl c =
    new skyvvasolutions.CallOutControl();

c.returnxml = true;
c.returnListRecord = true;
c.iscreatemessage = true;

List<String> lId = new List<String>();

for (Account a : [SELECT Id FROM Account]) {
    lId.add(a.Id);
}

skyvvasolutions.IServices.invokeCalloutV3(
    'Callout_Integration',
    'Account_Bat_Out-V3',
    lId,
    'BATCH',
    c
);

Where:

Click Execute to start processing.


- SKYVVA Starts Batch Apex Processing

After invokeCalloutV3() is executed, SKYVVA starts the outbound process using Batch Apex.

The initial processing package is based on the Transfer Package Size configured on the outbound Interface.

Developer Console
       |
       v
Execute Anonymous
       |
       v
invokeCalloutV3()
       |
       | Mode = BATCH
       v
Selected Record IDs
       |
       v
Transfer Package Size
       |
       v
Outbound Batch Apex

The records are processed according to the outbound Interface configuration.


- SKYVVA Prepares the Outbound Payload

During Batch Apex processing, SKYVVA prepares the data that will be sent to the target system.

This can include operations such as:

Salesforce Records
       |
       v
Read Record Data
       |
       v
Execute Mapping
       |
       v
Create Message
       |
       v
Serialize / Build Payload
       |
       v
Prepare Outbound Callout

Payload preparation can consume Salesforce resources such as Apex heap memory and CPU time.

For a large processing package or a mapping-heavy Interface, the Batch Apex execution can reach a Salesforce governor limit.


- Normal Processing When No Limit Occurs

When payload preparation completes successfully, SKYVVA executes the outbound callout.

Batch Apex
    |
    v
Prepare Payload
    |
    v
Outbound Callout
    |
    v
Target System
    |
    v
Processing Completed

The target system receives the outbound data and normal outbound processing completes.


Batch Apex Retry Processing

- Batch Apex Encounters a Supported Governor Limit

If the Batch Apex job encounters a supported governor limit during processing, the current Batch Apex execution fails.

For example:

Batch Apex
    |
    v
Prepare Payload
    |
    X
Governor Limit

A failure during payload preparation can occur before the outbound callout is sent.

Because the callout has not yet been sent for that failed processing, retrying the affected work does not duplicate data at the target merely because of that failed attempt.


- Salesforce Publishes BatchApexErrorEvent

For supported Batch Apex failures, Salesforce publishes the standard platform event:

BatchApexErrorEvent

SKYVVA uses this event to detect that the Batch Apex processing failed.

Governor Limit
      |
      v
Batch Apex Failed
      |
      v
BatchApexErrorEvent
      |
      v
Automated Process User
      |
      v
SKYVVA Error Handling

The event handling runs under the Salesforce Automated Process user.


- SKYVVA Identifies the Failed Processing

SKYVVA handles the Batch Apex error event and determines which outbound processing failed.

The retry process uses information from the failed Batch Apex execution so that the affected records can be processed again.

The original Transfer Package Size configured on the Interface is not permanently changed.


- SKYVVA Reduces the Processing Size

Instead of immediately processing the same large failed package again, SKYVVA retries the affected work using a smaller batch size.

Conceptually:

Original Batch
     |
     X
Limit Error
     |
     v
Split / Reduce Size
     |
     +-------------------+
     |                   |
     v                   v
Smaller Batch       Smaller Batch

The reduced size is used for retry processing only.

SKYVVA does not permanently modify the Transfer Package Size configured by the administrator on the Interface.


- New Batch Apex Retry Jobs Are Started

SKYVVA starts new Batch Apex processing for the smaller retry packages.

Failed Batch
     |
     v
BatchApexErrorEvent
     |
     v
Automated Process User
     |
     v
SKYVVA Retry
     |
     v
Smaller Processing Size
     |
     v
New Batch Apex Job

Each retry Batch Apex job receives a fresh Salesforce transaction context and governor limits.


- Retry Batch Prepares the Payload Again

The new Batch Apex job processes the affected records again.

Retry Batch Apex
       |
       v
Read Records
       |
       v
Execute Mapping
       |
       v
Create Message
       |
       v
Build Payload

If the smaller package can be processed within the Salesforce governor limits, payload preparation succeeds.


- SKYVVA Executes the Outbound Callout

After the retry payload is successfully prepared, SKYVVA sends the data through the configured outbound adapter.

Retry Batch Apex
       |
       v
Payload Prepared
       |
       v
Outbound Callout
       |
       v
Target System

The affected outbound records can then complete successfully without requiring the administrator to manually reduce the configured Transfer Package Size and execute the data again.


Retry Example

Assume the outbound Interface is configured with a Transfer Package Size and Batch Apex starts processing a large group of records.

Outbound Interface
       |
       v
Transfer Package Size
       |
       v
Large Batch
       |
       X
Governor Limit

For a supported error, Salesforce publishes BatchApexErrorEvent.

The event is handled under the Automated Process user, and SKYVVA reduces the processing size and retries the affected records.

Large Batch
    |
    X
Governor Limit
    |
    v
BatchApexErrorEvent
    |
    v
Automated Process User
    |
    v
SKYVVA Retry
    |
    v
Smaller Batch Size
    |
    +--------------------+
    |                    |
    v                    v
Retry Batch 1       Retry Batch 2
    |                    |
    v                    v
Build Payload       Build Payload
    |                    |
    v                    v
Callout             Callout
    |                    |
    v                    v
Target System       Target System

If a retry package still reaches a supported limit, the retry mechanism can continue reducing the amount of work where further splitting is possible.

Large Batch
    |
    X
Limit
    |
    v
Smaller Batch
    |
    X
Limit Again
    |
    v
Retry Smaller
    |
    v
New Batch Apex Job

When processing reaches the smallest possible unit and it still cannot complete within Salesforce limits, retry cannot solve the underlying payload/resource problem.

Processing must stop rather than retry indefinitely.


Important Limitation — REQUEST_RUNNING_TOO_LONG

Batch Apex Retry does not support the Salesforce error:

REQUEST_RUNNING_TOO_LONG

REQUEST_RUNNING_TOO_LONG is a Salesforce platform termination rather than a normal Apex exception.

For this error:

Therefore, SKYVVA cannot automatically start Batch Apex Retry for this error.

image

Monitor the Processing

1. Apex Jobs

Open Salesforce:

Setup → Apex Jobs

Check the status of:

A retry can result in additional Batch Apex jobs because the failed work is processed again using a smaller processing size.


2. SKYVVA Message Monitoring

Open SKYVVA Message Monitoring and verify the outbound messages.

Check whether the affected processing completes successfully after retry.

Message Monitoring is also useful for identifying records that remain unprocessed or failed.


3. SKYVVA Logs

Review the SKYVVA logs when investigating Batch Apex processing or retry errors.

The logs can help determine where the outbound processing failed and whether retry processing was started.


Full Processing Flow

image

Important Notes


Summary

Outbound Batch Apex Retry improves the reliability of SKYVVA outbound Batch Apex processing when a processing package reaches a supported Salesforce governor limit.

The administrator configures the Transfer Package Size on the outbound Interface. This value determines the initial processing package.

The user starts outbound processing from the Salesforce Developer Console by calling invokeCalloutV3() with BATCH mode.

SKYVVA processes the selected records through Batch Apex and prepares the outbound payload.

If processing succeeds, SKYVVA executes the outbound callout and sends the data to the target system.

If a supported governor limit causes the Batch Apex job to fail, Salesforce publishes BatchApexErrorEvent.

The event is handled under the Salesforce Automated Process user. Because SKYVVA retry processing executes in this context, the Automated Process user must have a valid SKYVVA license key.

SKYVVA identifies the failed processing, reduces the processing size, and starts new Batch Apex processing for the affected records.

If the smaller package succeeds, the outbound callout continues normally. If it reaches another supported limit, SKYVVA can continue reducing the processing size where further splitting is possible.

The original Transfer Package Size configured on the Interface remains unchanged.

The core processing flow is:

Transfer Package Size → invokeCalloutV3() → BATCH → Batch Apex → Supported Governor Limit → BatchApexErrorEvent → Automated Process User → SKYVVA Retry → Smaller Processing Size → New Batch Apex Job → Outbound Callout → Completed

Open this article in the interactive viewer →