Newer Version Available
Message Durability
Event Bus
With API version 37.0 and later, events are published to the event bus. Subscribers retrieve events from a channel on the event bus, including past events that are stored temporarily. The event bus decouples event publishers from event subscribers.

Event Replay Process
Each event message is assigned an opaque ID contained in the ReplayId field. The ReplayId field value, which is populated by the system when the event is delivered to subscribers, refers to the position of the event in the event stream. Replay ID values are not guaranteed to be contiguous for consecutive events. For example, the event following the event with ID 999 can have an ID of 1,025. A subscriber can store a replay ID value and use it on resubscription to retrieve events that are within the retention window. For example, a subscriber can retrieve missed events after a connection failure. Subscribers must not compute new replay IDs based on a stored replay ID to refer to other events in the stream.
This JSON message shows the replayId field in the event object for a generic event.
This JSON message shows the replayId field in the event object for a PushTopic event.
Platform event messages contain a replay ID when delivered to a CometD client. This JSON message shows the replayId field in the event object for the Low_Ink__e platform event.
This JSON message shows the replayId field in the event object for a Change Data Capture event.
Replaying Events
A subscriber can choose which events to receive, such as all events within the retention window or starting after a particular event. The default is to receive only the new events sent after subscribing. Events outside the retention period are discarded.
This high-level diagram shows how event consumers can read a stream of events by using various replay options.
To replay events, use the Streaming API endpoint.
After calling the setReplay() function on the extension, the events that the subscriber receives depend on the replay value parameter passed to setReplay().
After a client times out because it hasn’t reconnected within 40 seconds or a network failure has occurred, it attempts a new handshake request and reconnects. The replay extension saves the replay ID of the last message received and uses it when resubscribing. That way, the client receives only messages that were sent after the timeout and doesn’t receive duplicate messages that were sent earlier.
Code Samples
- Java Sample
- For a Java client sample that uses the CometD extension, see Example: Subscribe to and Replay Events Using a Java Client (EMP Connector).
- Lightning Component Sample
- For a sample that uses the empApi Lightning component, see Example: Subscribe to and Replay Events Using a Lightning Component.
- Visualforce Sample
- For a sample and code walkthrough that uses Visualforce and a CometD extension in JavaScript, see Example: Subscribe to and Replay Events Using a Visualforce Page.