Process Automation, Logic, and Integration27% of the exam

Platform event publishing, subscribers and Pub/Sub API

Publish Immediately versus Publish After Commit, what EventBus.publish's SaveResult really means, how platform event Apex triggers run, retry and resume, and which subscriber to use: an Apex trigger, empApi in a Lightning component, or Pub/Sub API with replay IDs and EventUuid deduplication.

Official exam objective
Given a scenario, identify the appropriate publish / subscribe logic for platform events.

~7 min read · 9 practice questions ·

What the exam expects

  • Choose Publish Immediately or Publish After Commit from whether subscribers need committed data.
  • Read EventBus.publish results correctly and get the final outcome with a publish callback.
  • Write and configure a platform event Apex trigger: batch size, running user, EventBus.RetryableException and setResumeCheckpoint.
  • Pick the subscriber: Apex trigger in the org, lightning/empApi in a component, Pub/Sub API for an external client.
  • Design a resilient external subscriber with replay IDs and deduplicate on EventUuid.

Key terms: publish behavior (Publish Immediately or Publish After Commit, set on the event definition), replay ID (the opaque position of a message in the event stream), EventUuid (the always-unique identifier of an event message), Pub/Sub API (gRPC-based API that publishes, subscribes and returns event schemas), PlatformEventSubscriberConfig (metadata that sets a trigger's running user and batch size).

Key facts

Default publish behavior
Detail
Publish Immediately, even if the transaction fails
Publish After Commit
Detail
Not published if the transaction fails; counts as a DML statement
isSuccess() true
Detail
Request queued; OPERATION_ENQUEUED; publish is asynchronous
Final publish result
Detail
Apex publish callback passed to EventBus.publish
Trigger batch
Detail
Up to 2,000 messages; synchronous limits
Trigger running user
Detail
Automated Process unless PlatformEventSubscriberConfig sets one
Retries
Detail
Initial run plus 9; then the error state
Retention
Detail
High-volume events kept 72 hours
Unique message ID
Detail
EventUuid, not ReplayId
Test delivery
Detail
After Test.stopTest() or Test.getEventBus().deliver()
Sources for this section (9)
  • When should an event use Publish After Commit?
  • Why can't a platform event trigger send email by default?
  • Why deduplicate on EventUuid instead of ReplayId?
  • What happens to DML already performed when a trigger throws `EventBus.RetryableException`?

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