Event Message Durability

Salesforce stores platform events and change data capture events for 72 hours. Using Pub/Sub API, you can retrieve events that are within the retention window. Retrieving stored events is helpful after the client disconnects and wants to catch up on missed events.

After the retention period, events are purged from the event bus. The purging process sometimes starts later, and as a result, platform events and change data capture events that are older than 72 hours can still be available. Salesforce doesn’t guarantee the storage of events beyond the retention period of 72 hours.

Each received event message is assigned an opaque ID contained in the Replay ID field, represented as ConsumerEvent.replay_id in the protocol specification. The Replay ID 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 aren’t guaranteed to be contiguous for consecutive events. 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.

The replay_id field value isn’t guaranteed to be unique when Salesforce maintenance activities occur, such as an org migration. To uniquely identify a platform event message, use the event id field. When publishing an event, the field is ProducerEvent.id. For more information, see Identify an Event with ProducerEvent.id and PublishResponse.correlationKey. For a received platform event message, use the ConsumerEvent.event.id field. The id field is present on platform events and not on change events.

Using the Subscribe RPC Method, a subscriber can choose which events to receive, such as all events 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.

Replay stored events

See Also