Tuesday 11 May 2021

Asynchronous Apex features and when to use each

 Hi,

Apex offers multiple ways for running your Apex code asynchronously.

We have to choose the asynchronous Apex feature that best suits your needs.

The following table lists the asynchronous Apex features and when to use each.

Asynchronous Apex FeatureWhen to Use
Queueable Apex
  • To start a long-running operation and get an ID for it
  • To pass complex types to a job
  • To chain jobs
Scheduled Apex
  • To schedule an Apex class to run on a specific schedule
Batch Apex
  • For long-running jobs with large data volumes that need to be performed in batches, such as database maintenance jobs
  • For jobs that need larger query results than regular transactions allow
Future Methods
  • When you have a long-running method and need to prevent delaying an Apex transaction
  • When you make callouts to external Web services
  • To segregate DML operations and bypass the mixed save DML error


Reference:

No comments:

Post a Comment

How to include a screen flow in a Lightning Web Component

 Hi, Assume  you have a flow called "Quick Contact Creation" and API Name for the same is "Quick_Contact_Creation". To i...