Suggested answer

Platform Events implement the publish-subscribe pattern. Publishers fire events using DML (EventBus.publish()) or Apex; subscribers listen via Apex triggers on the event, Flows, or CometD (streaming API for external systems).

Replay ID: Every published event is assigned a monotonically increasing Replay ID. Subscribers store the last-processed Replay ID and use it to replay missed events. Replay ID -1 retrieves the most recent event; -2 retrieves all events stored in the 72-hour retention window.

Gap Events: When a subscriber falls behind and events are delivered out of order or with gaps (e.g., due to connection drops), the subscriber can use the stored Replay ID to reprocess events from that point. An event gap occurs when the subscriber receives a Replay ID higher than the next expected — indicating missed events. The subscriber should replay from the last known good Replay ID.

Publish-After-Commit: Platform Events published within a transaction are only delivered to subscribers after the transaction commits. If the transaction rolls back, the events are not delivered — ensuring consistency.

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.

Plain text only, 3–2000 characters. A moderator reviews every comment before it is published.