Async Apex in Salesforce
Async Apex in Salesforce
Handling Large Data Volumes: Salesforce is not just a CRM; it’s a data
management platform. As your data volumes grow, you may encounter
issues with governor limits and execution timeouts. Asynchronous
processes help you overcome these limitations.
Batch Processing: One of the most common use cases for asynchronous
Apex is batch processing. It enables you to process records in chunks,
efficiently handling large data volumes.
Future Methods:
Example:
@future
email.setToAddresses(new List<String>{recipient});
email.setSubject(subject);
email.setPlainTextBody(body);
Messaging.sendEmail(new
List<Messaging.SingleEmailMessage>{email});
Queueable Apex:
Example:
System.enqueueJob(job);
Batch Apex:
Purpose: Batch Apex is used for processing large sets of records in smaller
chunks. It’s ideal for complex data processing tasks like data
transformations, updates, or inserts.
Example:
}
}
Database.executeBatch(batchJob);
Scheduled Apex:
Example:
Platform Events:
Example:
Asynchronous Triggers:
Example:
https://www.sfdckid.com/2019/07/salesforce-asynchronous-
apex.html#google_vignette