Anzeige

Asynchronous Apex .pptx

5. Sep 2022
Anzeige

Más contenido relacionado

Anzeige

Asynchronous Apex .pptx

  1. Salesforce Admin Group,Trichy Deep study on Asynchronous Apex
  2. Kadhar Basha J Salesforce Admin Group, Trichy Trailblazer Community Group Leader Sundaravel J Salesforce Admin Group, Trichy Trailblazer Community Group Co-Leader Salesforce Admin Group,Trichy
  3. Salesforce Admin Group,Trichy Speaker Mohamed Javith Shet Mohamad
  4. Today’s Agenda • Introduction • Asynchronous Apex • Scenarios • Demo • Questions & Answers
  5. Synchronous Apex • Occurring at the same time. • Quick and Immediate actions. • Transactions are immediate and serial. • Normal Governor Limits Asynchronous Apex • Not occurring at the same time. • Executes when resources are available. • Not immediate. • Higher Governor Limits.
  6. Governor Limits Description Synchronous Limit Asynchronous Limit Total number of SOQL queries issued 100 200 Total number of records retrieved by SOQL queries 50000 50000 Total number of records retrieved by Database.getQueryLocator 10000 10000 Total number of SOSL queries issued 20 20 Total number of records retrieved by a single SOSL query 2000 2000 Total number of DML statements issued 150 150 Total heap size 6 MB 12 MB Maximum CPU time on the Salesforce servers 10000 ms 60000 ms
  7. Example scenario Update a record Trigger will fire Need to insert more than 10000 or query 50000 records Use asynchronous apex Transaction completes. But asynchronous apex may still be running.
  8. Types
  9. Future Apex • @future annotation at the start of method. • Always method should be public static and return type should be void. • The specified parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types; future methods can’t take objects as arguments. • Future methods won’t necessarily execute in the same order they are called. In addition, it’s possible that two future methods could run concurrently, which could result in record locking if the two methods were updating the same record. • You’re limited to 50 future calls per Apex invocation, and there’s an additional limit on the number of calls in a 24-hour period. • Cannot call another future method from a future method.
  10. Batch Apex • Has a different syntax. • Every transaction starts with a new set of governor limits. • If one batch fails to process successfully, all other successful batch transactions aren’t rolled back. • Start, Execute and Finish are the 3 methods. • Can track the progress of batch in the apex job page in setup. • 5 batch jobs at a given time • You can call another batch from batch or queue but not future method. • What happens when more than 5 batch jobs are invoked?
  11. Queueable Apex • Similar to future apex. • Accepts non primitive datatypes too. • Can call another queue. (Only one) • Progress can be tracked in apex batch jobs page. • You can add up to 50 jobs to the queue with System.enqueueJob in a single transaction.
  12. Schedulable Apex • Runs apex class at a specified time and frequency. • Can be scheduled in UI or using cron jobs. • Scheduled jobs can be tracked from scheduled jobs page in setup. • You can only have 100 scheduled Apex jobs at one time Note: Always asynchronous apex should be executed within startTest() and stopTest().
Anzeige