Activity Forums Salesforce® Discussions What is the difference between future apex and batch apex in Salesforce?

  • Anjali

    Member
    August 6, 2018 at 6:09 am

    Future Annotation is used to separate methods that are to be executed asynchronously.If Future Annotation is not used in a web service callout, the thread will wait until the response comes and other processes will not be executed.

    Batch Apex is used to separate tasks that are going to handle more records in background process. Batch Apex also runs asynchronously.If Batch Apex is not used for handling bulk records, we will hit governor limits set by Salesforce.com.

  • Parul

    Member
    September 7, 2018 at 6:26 pm

    Hi Anurag,

    Batch Apex: 

    Batch apex allows you to define a job that can be divided into manageable chunks, where each chunk can be proceed separately.

    In batch apex, it will fetch all records which you want perform the field update and divide them into list of 200 records and every 200 records operation is performed separately.

    Batch Apex is exposed as an interface that must be implemented by the developer. Batch jobs can be programmatically invoked at runtime using Apex.

    Batch jobs can also be programmatically scheduled to run at specific times using the Apex Scheduler, or scheduled using the Schedule Apex page in the Salesforce user interface.

    Batch Apex is used to separate tasks that are going to handle more records(complex long running jobs) in background process. Batch Apex also runs asynchronously.
    If Batch Apex is not used for handling bulk records, we will hit governor limits set by Salesforce.com.

    Future Annotation:  @future

    Future Annotation is used to separate methods that are to be executed asynchronously.
    If Future Annotation is not used in a web service callout, the thread will wait until the response comes and other processes will not be executed.

     

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos