Knowing when to use what

Asynchronous Apex, in its various forms, is incredibly useful. By trading synchronous execution of your code for relaxed or reset governor limits, you can process massive numbers of records, call out to web services without holding up your users, and, as of the Spring '15 release, you can even write fault tolerant asynchronous callouts. Knowing when to use which type of Asynchronous Apex, however, can be difficult. With that in mind, here are some guidelines:

  • If you are manipulating more than 2000 records, use Batchable Apex.
  • While you can directly schedule Batchable Apex, it is almost always preferable to wrap the batch Apex execution in a scheduled class, as this provides much more flexibility regarding execution time ...

Get Mastering Application Development with Force.com now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.