Close Menu
SalesforceCodex
    Facebook X (Twitter) Instagram
    Trending
    • The Ultimate Guide to Data Cleanup Techniques for Salesforce
    • How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI
    • Top Mistakes Developers Make in Salesforce Apex Triggers
    • Introducing Agentforce3 to Salesforce Developers
    • The Ultimate Guide to Apex Order of Execution for Developers
    • How to Handle Bulkification in Apex with Real-World Use Cases
    • How to Confidently Manage Transactions in Salesforce Apex
    • Building a Dynamic Tree Grid in Lightning Web Component
    Facebook X (Twitter) Instagram
    SalesforceCodex
    Subscribe
    Saturday, August 2
    • Home
    • Salesforce Platform
      • Architecture
      • Apex
      • Lightning Web Components
      • Integration
      • Flows & Automation
      • Best Practices
      • Questions
      • News
      • Books Testimonial
    • Industries
      • Artificial Intelligence
    • Hire Me
    • Certification
      • How to Prepare for Salesforce Integration Architect Exam
      • Certification Coupons
    • Downloads
      • Salesforce Release Notes
      • Apex Coding Guidelines
    • About Us
      • Privacy Policy
    • Contact Us
    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 Sahni6 Mins Read

    How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI

    July 28, 2025
    By Dhanik Lal Sahni7 Mins Read

    Top Mistakes Developers Make in Salesforce Apex Triggers

    July 25, 2025
    By Dhanik Lal Sahni14 Mins Read

    The Ultimate Guide to Apex Order of Execution for Developers

    July 20, 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
    SFBenTopDeveloper
    Ranked #4 Salesforce Developer Blog by ApexHours.com
    ApexHoursTopDevelopers
    Categories
    Archives
    Tags
    apex (116) apex best practices (5) apex code best practice (10) apex code optimization (6) Apex logging (4) apex rest (11) apex trigger best practices (6) architecture (22) Asynchronous apex (9) AWS (5) batch apex (10) best code practice (4) code optimization (9) custom metadata types (5) design principle (9) flow (16) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (66) lightning-combobox (5) lightning-datatable (10) lightning component (32) Lightning web component (64) lwc (53) named credential (8) news (4) optimize apex (5) optimize apex code (6) optimize apex trigger (5) Permission set (4) Queueable (9) queueable apex (4) rest api (23) salesforce (150) salesforce apex (52) salesforce api integration (5) Salesforce Interview Question (5) 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

    MailChimp

    Expert Salesforce Developer and Architect
    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • The Ultimate Guide to Data Cleanup Techniques for Salesforce
    • How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI
    • Top Mistakes Developers Make in Salesforce Apex Triggers
    • Introducing Agentforce3 to Salesforce Developers
    • The Ultimate Guide to Apex Order of Execution for Developers
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • Top 10 Salesforce CRM Trends to Watch in 2025 July 18, 2025
    • Discover the Top 10 Salesforce AppExchange Apps to Boost Productivity July 10, 2025
    • Top 20 Salesforce Data Cloud Interview Questions & Answers for Admins June 5, 2025
    • 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
    Archives
    Categories
    Tags
    apex (116) apex best practices (5) apex code best practice (10) apex code optimization (6) Apex logging (4) apex rest (11) apex trigger best practices (6) architecture (22) Asynchronous apex (9) AWS (5) batch apex (10) best code practice (4) code optimization (9) custom metadata types (5) design principle (9) flow (16) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (66) lightning-combobox (5) lightning-datatable (10) lightning component (32) Lightning web component (64) lwc (53) named credential (8) news (4) optimize apex (5) optimize apex code (6) optimize apex trigger (5) Permission set (4) Queueable (9) queueable apex (4) rest api (23) salesforce (150) salesforce apex (52) salesforce api integration (5) Salesforce Interview Question (5) 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.