Close Menu
SalesforceCodex
    Facebook X (Twitter) Instagram
    Trending
    • How to Build a Generic Modal Window in Lightning Web Component
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    • Top 10 PMD Issues Salesforce Developers Should Focus on in Apex
    • How to Use Graph API for Outlook-Salesforce Connection
    Facebook X (Twitter) Instagram
    SalesforceCodex
    Subscribe
    Saturday, May 31
    • Home
    • Architecture
    • Salesforce
      • News
      • Apex
      • Integration
      • Books Testimonial
    • Questions
    • Certification
      • How to Prepare for Salesforce Integration Architect Exam
      • Certification Coupons
    • Integration Posts
    • Downloads
    • About Us
      • Privacy Policy
    SalesforceCodex
    Home»Salesforce»Revisit Asynchronous Apex : Type and Usage

    Revisit Asynchronous Apex : Type and Usage

    Dhanik Lal SahniBy Dhanik Lal SahniJuly 16, 20181 Comment3 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Revisit Asynchronous Apex : Type and Usage
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Asynchronous Apex
    Asynchronous Apex is used to run processes in a separate thread, at a later time.

    An asynchronous process is a process or function that executes a task in the background without the user having to wait for the task to finish.
    In real work example, let us we want to send Adobe E-Sign document to customer when any application is created. Adobe esign normally takes 5-15 seconds to generate agreement. we can not hold customer till agreement is generated. So we can use some Asynchronous processing so that agreement generation done in background. Email will automatically sent to applicant for signature.

    Benefit of Asynchronous Apex :
    User efficiency
    It is always better to give high performing application to user. If user will keep waiting for output they will get annoyed. So it is better, we can get task registered and then we can do action in background service. This way user experience will be better.
    Yes, this will be dependent on type of action need to be done.

    Scalability
    We can take action based on availability of required resources using platform events.

    Higher Governor Limits
    Asynchronous processes are executed in a new thread, with higher governor and execution limits.

    Different Types of Asynchronous Apex

    Future Methods:
    Future Methods, Run in their own thread. These methods only start when resources are available. This is mainly used when web service callout is required.

    global class FutureClass
    {
        @future
        public static void myFutureMethod()
        {   
             // Perform some operations
        }
    }
    

    Batch Apex:
    These are used when we run large jobs that would exceed normal processing limits.Using Batch Apex, you can process records asynchronously in batches to stay within platform limits

    global class MyBatchClass implements Database.Batchable {
        global (Database.QueryLocator | Iterable) start(Database.BatchableContext bc) {
            // collect the batches of records or objects to be passed to execute
        }
        global void execute(Database.BatchableContext bc, List

    records){ // process each batch of records } global void finish(Database.BatchableContext bc){ // execute any post-processing operations } }

    Queueable Apex:
    This is extension of future methods. We can chaining in queueable jobs. You can chain one job to another by starting a second job from a running job. Chaining jobs is useful if you need to do some processing that depends on another process to have run first. In chaining we get output as ID, which can be use to manage that job. Example for this is

    public class AsyncExecutionController implements Queueable {
         public void execute(QueueableContext context) {
              Account a = new Account(Name='Dhanik',Phone='(0123) 555-1212');
              insert a; 
         }
    }
    
    
    //jobid can be used for chaning or managing it.
    ID jobID = System.enqueueJob(new AsyncExecutionController ());
    

    Scheduled Apex:

    Apex Scheduler lets you delay execution so that you can run Apex classes at a specified time.This is ideal for daily or weekly maintenance tasks using Batch Apex.

    global class SomeClass implements Schedulable {
        global void execute(SchedulableContext ctx) {
            // awesome code here
        }
    }
    

    Summary:
    Asynchronous processing has lower priority than real time interaction via the browser and API. To ensure there are sufficient resources to handle an increase in computing resources, the queuing framework monitors system resources such as server memory and CPU usage and reduce asynchronous processing when thresholds are exceeded.

    apex Asynchronous apex batch processing future method Queueable salesforce Scheduled Apex
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleModel Popup in Salesforce Lightning
    Next Article Health Tips for Software Engineers
    Dhanik Lal Sahni
    • Website

    Related Posts

    By Dhanik Lal Sahni4 Mins Read

    How to Build a Generic Modal Window in Lightning Web Component

    May 26, 2025
    By Dhanik Lal Sahni6 Mins Read

    Top 10 Salesforce Flow Features of Salesforce Summer ’25

    May 11, 2025
    By Dhanik Lal Sahni6 Mins Read

    Unlock the Power of Vibe Coding in Salesforce

    April 30, 2025
    View 1 Comment

    1 Comment

    1. Pingback: Avoid Batch Apex and Use Queueable Class | SalesforceCodex

    Leave A Reply Cancel Reply

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • How to Build a Generic Modal Window in Lightning Web Component
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    • Top Reasons to Love Salesforce Trailhead: A Comprehensive Guide December 5, 2024
    • How to Utilize Apex Properties in Salesforce November 3, 2024
    • How to Choose Between SOQL and SOSL Queries July 31, 2024
    Archives
    Categories
    Tags
    apex (111) apex code best practice (8) apex rest (11) apex trigger best practices (4) architecture (22) Asynchronous apex (9) AWS (5) batch apex (9) batch processing (4) code optimization (8) code review tools (3) custom metadata types (5) design principle (9) file upload (3) flow (15) future method (4) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (64) lightning-combobox (5) lightning-datatable (10) lightning component (30) Lightning web component (62) lwc (51) named credential (8) news (4) optimize apex code (4) Permission set (4) pmd (3) Queueable (9) rest api (23) S3 Server (4) salesforce (141) salesforce apex (46) salesforce api (4) salesforce api integration (5) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • How to Build a Generic Modal Window in Lightning Web Component
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    • Top Reasons to Love Salesforce Trailhead: A Comprehensive Guide December 5, 2024
    • How to Utilize Apex Properties in Salesforce November 3, 2024
    • How to Choose Between SOQL and SOSL Queries July 31, 2024
    Archives
    Categories
    Tags
    apex (111) apex code best practice (8) apex rest (11) apex trigger best practices (4) architecture (22) Asynchronous apex (9) AWS (5) batch apex (9) batch processing (4) code optimization (8) code review tools (3) custom metadata types (5) design principle (9) file upload (3) flow (15) future method (4) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (64) lightning-combobox (5) lightning-datatable (10) lightning component (30) Lightning web component (62) lwc (51) named credential (8) news (4) optimize apex code (4) Permission set (4) pmd (3) Queueable (9) rest api (23) S3 Server (4) salesforce (141) salesforce apex (46) salesforce api (4) salesforce api integration (5) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Facebook X (Twitter) Instagram Pinterest YouTube Tumblr LinkedIn Reddit Telegram
    © 2025 SalesforceCodex.com. Designed by Vagmine Cloud Solution.

    Type above and press Enter to search. Press Esc to cancel.

    Ad Blocker Enabled!
    Ad Blocker Enabled!
    Our website is made possible by displaying online advertisements to our visitors. Please support us by disabling your Ad Blocker.