Salesforce Decode
Salesforcedecode
Back to questions
ApexAdvancedplatform-eventsevent-drivenpub-sub

Implement Platform Event publishing and subscribing patterns

Real World Scenario

Order status changes must notify warehouse, analytics, and email service with at-least-once delivery tolerance.

Expected Answer

• Define high-volume vs standard event based on volume and durability needs • Publish after DML commit using EventBus.publish in after trigger • Subscribers in separate transaction—design idempotent processing • Replay ID tracking for subscriber recovery after downtime • Payload minimal: IDs and change type; subscribers query fresh data • Monitor event publish failures and subscriber error logs • Complementary CDC when external systems need full field change detail

Follow-Up Questions & Answers

Click to expand — each follow-up includes a direct, interview-ready answer

Main difference: use case and scale. Define high-volume vs standard event based on volume and durability needs. Publish after DML commit using EventBus.publish in after trigger. Pick based on your integration pattern and team capability. Platform Events are async contracts—subscribers must tolerate duplicate and out-of-order delivery. Optimize for scale and operational observability.

Architect Perspective

Platform Events are async contracts—subscribers must tolerate duplicate and out-of-order delivery.