Why Run Work Asynchronously?
By the end of this lesson, you'll be able to:
- Explain what running Apex asynchronously actually means
- Recognize the specific problems asynchronous Apex solves
- Connect this directly to Module 36's trigger-callout constraint
Prerequisites: Module 37: "Project: REST Integration"
A promise finally kept
Module 36's very first lesson stated plainly: "a callout can never run directly inside a trigger... moving a callout to run asynchronously sidesteps this constraint, covered in a later module." This is that module. Every synchronous limitation flagged since Module 25 — the 10-second callout window, the 100-query ceiling, the "can't callout from a trigger" rule — gets a genuine answer here.
What "asynchronous" actually means
// Synchronous: this line blocks until the callout finishes
HttpResponse response = new Http().send(request);
// Asynchronous: this schedules the work to run in a SEPARATE,
// later transaction, and the current transaction continues immediately
System.enqueueJob(new MyQueueableClass());
Running code asynchronously means it doesn't execute as part of the current transaction at all — it's queued to run in its own, separate transaction, at a time the platform decides (usually within seconds, but not guaranteed instantly). The current transaction doesn't wait for it; it continues immediately.
The two problems this solves
- Callouts from a trigger. A trigger can never make a synchronous callout directly (Module 36) — but it can enqueue asynchronous work that makes the callout in its own separate transaction.
- A fresh set of governor limits. Each asynchronous transaction gets its own complete budget — 100 queries, 150 DML statements, all reset — genuinely useful for processing more data than a single synchronous transaction could handle (Module 25's limits, given more room to work with).
Exercise
As a comment, explain how asynchronous Apex resolves the exact constraint Module 36 flagged about triggers and callouts.
Show hint
Refer back to what Module 36 said a trigger could never do directly.
Why Run Work Asynchronously? Quiz
My Notes
Log in to keep private notes on this lesson.
Questions about this lesson
No questions yet — be the first to ask.
Log in to ask a question about this lesson.
Summary
Asynchronous Apex runs code in a separate transaction, later, with its own fresh governor limits — solving exactly the problems Module 36 flagged but couldn't fully resolve: callouts from triggers, and work too large for one synchronous transaction.