Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Episode 19 - Asynchronous Apex - Batch apex & schedulers

541 views

Published on

Getting started with Asynchronous Apex in Salesforce

Published in: Education
  • Be the first to comment

  • Be the first to like this

Episode 19 - Asynchronous Apex - Batch apex & schedulers

  1. 1. Path to Code Begin Your Salesforce Coding Adventure
  2. 2. Episode 19 Asynchronous Apex - Batch Apex & Schedulers
  3. 3. • Enterprise Solutions Architect • Global Community Speaker Jigar Shah @jigarshah189
  4. 4. Agenda • Demystifying Async Processing • Understanding Batch Apex • Anatomy of a Batch Job • Understanding Scheduled Apex • Decoding Cron Expressions • Considerations for Scheduled Apex • Q&A
  5. 5. Some Housekeeping Rules… • Mute your mic • Keep adding questions in Zoom Q&A Window • No questions are silly! • Questions will be answered in the last 15 mins of this session
  6. 6. Demystifying Asynchronous Processing Start Immediate Results Required? Asynchronous Processing Synchronous Processing Future Methods Queueable Apex Batch Apex Scheduled Apex Triggers • User Efficiency • Scalability • Higher Limits Yes No
  7. 7. Understanding Batch Apex Start Success Failure Partial SuccessJob (Job 1) Job 1 Job n Job Submitted QUEUED FAILED COMPLETED PROCESSINGPREPARING Job 2 ABORTED start() is invoked & processing chunks are created
  8. 8. Anatomy of a Batch Job 1 2 3 4
  9. 9. Demo 1 Writing Your First Batch Job
  10. 10. Maintaining State in Batches
  11. 11. Demo 2 Writing Stateful Batch Jobs
  12. 12. Considerations for Batch Apex  50 million records can be processed  Use Batch Apex only if there are more than 1 batches to be processed else opt for Queueable Apex  Fine tune your SOQL query to minimize QueryLocator records  Invocation from Triggers may lead to uncontrolled executions  Implement Database.AllowsCallouts to make Webservice calls
  13. 13. Understanding Scheduled Apex Start Success Failure Partial SuccessJob (Job 1) Job 1 Job n Job Submitted QUEUED FAILED COMPLETED PROCESSING SCHEDULING Job 2 ABORTED Schedules based on User’s Timezone & executes in System Mode
  14. 14. Decoding Cron Expressions
  15. 15. Anatomy of a Scheduled Apex Job 1 2
  16. 16. Demo 3 Writing a Cron Job
  17. 17. Considerations for Schedulers  Maximum 100 jobs can be scheduled concurrently  Limit on maximum number of Scheduled Apex invocations on a per 24 hour basis  Synchronous Web service callouts are not supported from Scheduled Apex
  18. 18. Resources  Custom Iterators  Apex Developer Guide  Execution Governor Limits
  19. 19. Trailhead Modules Async Apex
  20. 20. Q & A
  21. 21. Thank You
  22. 22. Subscribe

×