The Event Bus is not configured directly. Configuration happens at the event-type level (define a Platform Event, enable CDC on an object) and at the subscriber level (Apex trigger, flow, external Pub/Sub client). The design pattern below covers the recommended approach.
- Define the event
For Platform Events: Setup, Platform Events, New Platform Event. Set name, API name, publish behaviour (Publish Immediately or Publish After Commit). Add custom fields representing the event payload. For CDC: Setup, Change Data Capture, enable on the desired standard or custom objects.
- Wire the publisher
Apex: EventBus.publish(new MyEvent__e(Field1__c = value)). Flow: Action element, Publish Platform Event. External: POST to /services/data/vXX.X/sobjects/MyEvent__e/. Pick the path matching the publisher''s context.
- Wire the subscriber
Apex Trigger: trigger MyEventTrigger on MyEvent__e (after insert). Flow: Platform Event-Triggered Flow on the event type. External: Pub/Sub API client connecting via gRPC with appropriate auth.
- Test end-to-end
Publish an event in sandbox. Verify every subscriber fires. Check Event Monitoring for the publish and delivery records. Test the failure path: simulate a subscriber outage and replay events using the replay ID.
- Monitor in production
Setup, Event Monitoring, look at daily event counts and delivery success rates. Build alerts on event allocation usage; surprise spikes mean either traffic growth or a runaway publisher.
Standard Platform Events (baseline allocation, 72-hour retention) or High-Volume (extended allocation, up to 7-day retention, separate license).
Publish Immediately (event delivers as soon as the publish call returns) or Publish After Commit (event waits for the surrounding database transaction to commit).
Apex Trigger, Flow, Pub/Sub API (gRPC, modern), CometD (legacy, feature-frozen). Pick based on subscriber location and language.
Subscribers can replay from any event in the retention window using a replay ID, or skip ahead to live events. Track replay ID on the subscriber side to handle restarts gracefully.
- Events persist for 72 hours on Standard tier. Subscribers offline longer than that lose events; build a separate catch-up mechanism for long outages.
- Daily event allocation counts both publish and delivery. A high fan-out event with many subscribers consumes the allocation faster than the publish count alone suggests.
- Publish After Commit waits for the transaction to commit. Publish Immediately fires even if the transaction later rolls back, producing phantom events. Pick carefully.
- Pub/Sub API is the modern subscriber path. CometD still works but is feature-frozen; new external integrations should use Pub/Sub.
- Apex triggers on Platform Events run async, in a separate transaction from the publish. Errors in the trigger do not roll back the publish.