Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

Ankit Jain

Salesforce Technical Architect At MNC


Salesforce 18X Certified
Active in Salesforce Events
https://www.linkedin.com/in/ankit-jain-sfdc/
To be Updated for future Sessions

Connect with me
https://www.linkedin.com/in/ankit-jain-sfdc/

Join the below Whatsapp Group


https://chat.whatsapp.com/FEr8DHP42RkE8Vo5
RX2K1P
Want to Have session with me
• https://topmate.io/ankitjainsfdc book the
session
Asynchronous Apex
Why Asyn Apex
• 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.

• Improved User Experience: Users expect responsive applications.
Asynchronous processing ensures that your Salesforce application
remains responsive and doesn’t get bogged down by time-consuming
operations.

• Long-Running Operations: Certain tasks, such as data migrations,
integrations, and batch processing, can take a significant amount of
time. Asynchronous Apex allows you to delegate these tasks to run in
the background, freeing up resources for other operations.
Features of Async Apex
• Queueable Apex
• Scheduled Apex
• Batch Apex
• Future Methods
Future Method
• A future method runs in the background, asynchronously.

• You can call a future method for executing long-running operations, such as
callouts to external Web services or any operation you’d like to run in its
own thread, on its own time. You can also use future methods to isolate
DML operations on different sObject types to prevent the mixed DML error.

• Each future method is queued and executes when system resources


become available. That way, the execution of your code doesn’t have to
wait for the completion of a long-running operation.

• A benefit of using future methods is that some governor limits are higher,
such as SOQL query limits and heap size limits.
Business Case of Future Method
• 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
Setup Objects
• Setup objects in Salesforce are primarily
related to system configuration and
administration. Examples of setup objects
include User, Profile, Role, Permission Set, and
Organization. These objects store critical
information that governs the behavior and
security of the Salesforce instance
Non Setup Objects
• Other than Setup like Custom
Objects,Standard Objects
Future Method code
• global class FutureMethodExample
• {
• @future(callout=true)
• public static void getStockQuotes(String acctName)
• {
• // Perform a callout to an external service
• }

• }
Queable Apex
• To start a long-running operation and get an ID
for it

• To pass complex types to a job

• To chain jobs
Queable Code Example
Transaction Finalizers

• The Transaction Finalizers feature enables you to attach


actions, using the System.Finalizer interface, to asynchronous
Apex jobs that use the Queueable framework. A specific use
case is to design recovery actions when a Queueable job fails.
• The Transaction Finalizers feature provides a direct way for you
to specify actions to be taken when asynchronous jobs succeed
or fail. Before Transaction Finalizers, you could only take these
two actions for asynchronous job failures:Poll the status
of AsyncApexJob using a SOQL query and re-enqueue the job if
it fails
• Fire BatchApexErrorEvents when a batch Apex method
encounters an unhandled exception
Batch Class
• 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
Code Live In Action
Scheduled Apex
• To schedule an Apex class to run on a specific
schedule
Any Questions?

You might also like