What are Platform Events and what is the difference between publish-immediately and publish-after-commit?
Suggested answer
Platform Events are Salesforce's publish-subscribe messaging system. Events are published and consumed by triggers, flows, processes, or external subscribers. Publish Immediately: The event is published as soon as EventBus.publish() is called, regardless of whether the publishing transaction commits or rolls back. Use when the event must fire even if the publisher's transaction fails (e.g., sending error notifications). Publish After Commit: The event is only published after the publishing transaction successfully commits. This is the default. Ensures subscribers don't react to events from rolled-back transactions. Replay ID: Each published event has a Replay ID. Subscribers can specify a replay ID to re-subscribe from a past event (up to 72 hours retention) — useful for recovering from subscriber downtime. External subscribers use CometD streaming to receive events.
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.