Process Automation, Logic, and Integration27% of the exam

Choosing Queueable, Batch, Scheduled or future Apex

The advanced async decisions PD II tests: why Queueable replaces future methods, bulk-safe enqueueing from triggers, Database.Stateful and callouts in Batch Apex, callouts from Scheduled Apex, transaction finalizers, and async as the fix for mixed DML and slow saves.

Official exam objective
Analyze a set of requirements and determine the benefits of using asynchronous Apex coding.

~8 min read · 9 practice questions ·

What the exam expects

  • Name what asynchronous Apex gives a requirement (a save that no longer waits, higher limits, scalability) and what it does not (a guaranteed start time).
  • Replace a future method with Queueable Apex when the job needs sObjects, a job ID, chaining or callouts, and spot code that will not compile.
  • Read a trigger or batch class and find the async bug: too many System.enqueueJob calls, state lost between execute calls, a callout from the wrong context.
  • Design failure recovery for a Queueable job with a transaction finalizer.
  • Fix a mixed DML error by moving setup-object DML into an asynchronous job.

The per-transaction limits and the basic future/Queueable/Batch/Scheduled overview are covered in the Platform Developer guide's Governor limits and asynchronous Apex; this unit teaches the layer above it.

Key terms: Queueable (a class implementing Queueable, added to the queue with System.enqueueJob), chaining (a running job enqueuing the next one), Database.Stateful (keeps instance variables across batch transactions), Database.AllowsCallouts (marker interface that permits callouts in Queueable and Batch Apex), transaction finalizer (a System.Finalizer attached to a Queueable job that runs after it succeeds or fails).

Key facts

Future method signature
Detail
Static, void; parameters are primitives or arrays/collections of primitives
Queueable extras
Detail
Job ID, non-primitive member variables, chaining
Chaining
Detail
One child job per executing job; depth 5 in Developer and Trial orgs
enqueueJob per transaction
Detail
50 synchronous, 1 asynchronous, 50 for Bulk API
Rolled-back enqueuing transaction
Detail
Queued jobs are not processed
QueryLocator
Detail
Up to 50 million records; scope default 200, maximum 2,000
Database.Stateful
Detail
Keeps instance variables; statics still reset
Batch concurrency
Detail
Up to 5 queued or active jobs; flex queue holds 100
Scheduled Apex
Detail
100 jobs at once; no synchronous callouts
Finalizer retries
Detail
Re-enqueue up to 5 consecutive failures; one async job per finalizer
Daily async allowance
Detail
250,000 or 200 × user licenses, whichever is greater
Sources for this section (6)
  • Why does a future method reject an sObject parameter?
  • When does a batch class need `Database.Stateful`?
  • When must a scheduled job hand its callout to another class?
  • What happens to a Queueable enqueued by a transaction that later rolls back?

The questions are free to read. Answers with their sources and self-grading are included with the pack.

Keep reading with the Platform Developer II pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 28 lessons of the Platform Developer II guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Inline practice questions and one-click topic practice (9 questions for this lesson)
  • An official source cited for every claim
  • An AI tutor that answers from the guide
  • Unlimited timed practice exams

Practice for the Platform Developer II exam