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.
Scope
This document covers:
- Outbound processing
invokeCalloutV3()- Developer Console / Execute Anonymous
- Execution mode =
BATCH - Interface API Version V3
- Transfer Package Size
- Batch Apex processing
BatchApexErrorEvent- Automated Process user
- Automatic retry with a smaller processing size
- Monitoring the retry processing
REQUEST_RUNNING_TOO_LONGlimitation
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:
- The SKYVVA Integration is configured.
- The outbound Interface is configured.
- The Interface uses Interface API Version V3.
- The outbound adapter/target connection is configured correctly.
- Salesforce records are available for outbound processing.
- Transfer Package Size is configured on the outbound Interface.
- 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:
- Parent message processing completed.
- Child messages were missing.
- The Automated Process user did not have a SKYVVA license key.
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
| Processing | User Context | Purpose |
|---|---|---|
| Initial execution | Salesforce user | Manually executes invokeCalloutV3() |
| Initial Batch Apex | Started by invokeCalloutV3() | Processes outbound records |
| Error event | Salesforce | Publishes BatchApexErrorEvent |
| Retry event handling | Automated Process user | Executes SKYVVA retry handling |
| Retry Batch Apex | SKYVVA retry processing | Processes failed work again using a smaller size |
Important: The Automated Process user is required for the retry processing triggered byBatchApexErrorEvent. It is not the user that manually executesinvokeCalloutV3()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:
- Reading Salesforce records
- Reading related records
- Executing mappings
- Creating SKYVVA messages
- Serializing data
- Building the outbound payload
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:
Callout_Integration= Integration nameAccount_Bat_Out-V3= outbound Interface namelId= list of Salesforce record IDsBATCH= Batch Apex execution modec=CallOutControl
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:
- The Batch Apex job is terminated by Salesforce.
- The Apex job status becomes Failed.
- The error cannot be caught by Apex
try/catch. - The Batch
finish()method may not run. - Salesforce does not publish a
BatchApexErrorEvent.
Therefore, SKYVVA cannot automatically start Batch Apex Retry for this error.
Monitor the Processing
1. Apex Jobs
Open Salesforce:
Setup → Apex Jobs
Check the status of:
- The original Batch Apex job
- Failed Batch Apex processing
- Retry Batch Apex jobs
- Completed Batch Apex jobs
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
Important Notes
- Outbound processing is started manually from the Salesforce Developer Console in this use case.
- The API method is
invokeCalloutV3(). - The execution mode must be
BATCH. - The Interface uses Interface API Version V3.
- Transfer Package Size is configured on the outbound Interface.
- Transfer Package Size defines the initial processing package.
- A large Transfer Package Size can result in higher resource usage during payload preparation.
- A supported governor limit can cause the Batch Apex execution to fail.
- Retry depends on Salesforce publishing
BatchApexErrorEvent. BatchApexErrorEventhandling runs under the Salesforce Automated Process user.- The Automated Process user must have a valid SKYVVA license key for SKYVVA retry processing.
- The Automated Process user is different from the user who manually executes
invokeCalloutV3(). - SKYVVA retries failed processing using a smaller processing size.
- The configured Interface Transfer Package Size is not permanently changed by automatic retry.
- A retry can create multiple smaller Batch Apex jobs.
- If a retry package still reaches a supported limit, further splitting can occur where possible.
- If the smallest possible processing unit still exceeds a Salesforce limit, retry cannot resolve the failure.
REQUEST_RUNNING_TOO_LONGcannot be automatically retried because Salesforce does not publishBatchApexErrorEventfor that termination.
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

