Batch Request in Salesforce

Executes up to 25 subrequests in a single request. The response bodies and HTTP statuses of the subrequests in the batch are returned in a single response body. Each subrequest counts against rate limits unlike Composite Request.

Subrequests execute serially in their order in the request body. When a subrequest executes successfully, it commits its data. Commits are reflected in the output of later subrequests. If a subrequest fails, commits made by previous subrequests are not rolled back. If a batch request doesn’t complete within 10 minutes, the batch times out and the remaining subrequests aren’t executed.

haltOnError
Controls whether Salesforce should stop processing subrequests if a subrequest fails. The default is false.
If the value is false and a subrequest in the batch doesn’t complete, Salesforce attempts to execute the subsequent subrequests in the batch.
If the value is true and a subrequest in the batch doesn’t complete due to an HTTP response in the 400 or 500 range, Salesforce halts execution. It returns an HTTP 412 status code and a BATCH_PROCESSING_HALTED error message for each subsequent subrequest. 

 
Different between Composite and Batch in Composite Resources
Composite

In a subrequest’s body, you specify a reference ID that maps to the subrequest’s response. You can then refer to the ID in the url or body fields of later subrequests by using a JavaScript-like reference notation.

allOrNone flag is available for roll back option.

Batch
Subrequests are independent, and you can’t pass information between them. Subrequests execute serially in their order in the request body.

If a batch request doesn’t complete within 10 minutes, the batch times out and the remaining subrequests aren’t executed.

Leave a Reply