Newer Version Available
Introducing Generic Streaming
- Broadcasting notifications to specific teams or to your entire organization
- Sending notifications for events that are external to Salesforce
- A StreamingChannel that defines the channel, with a name that is case-sensitive
- One or more clients subscribed to the channel
- The Streaming Channel Push REST API resource that lets you monitor and invoke push events on the channel
Replay Generic Streaming Events with Durable Generic Streaming
The 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. Streaming API uses an event framework that decouples event producers from event consumers. Therefore, a subscriber can retrieve events at any time and isn’t restricted to listen to events at the time they’re sent. Events outside the 24-hour retention period are discarded.
API Version
Replaying events is supported with API version 36.0 and later.
Event Numbering
Each broadcasted event is assigned a numeric ID. IDs are incremented sequentially, but they’re 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. However, each ID is guaranteed to be higher than the ID of the previous event. The ID is unique for the org and the channel. The IDs of deleted events aren’t reused.
The ID is added in the replayId field of the notification message. For example, this JSON message shows the replayId field in the event object.
1{
2 "clientId":"a1ps4wpe52qytvcvbsko09tapc",
3 "data":{
4 "event":{
5 "createdDate":"2015-11-13T19:05:28.334Z",
6 "replayId":55
7 },
8 "payload":"This is a message."
9 },
10 "channel":"/u/TestStreaming"
11}Replaying Events
The following diagram shows a high-level overview of a stream of events and how event consumers can read events by using various replay options.
To replay events, use the following endpoint.
1https://Salesforce_Instance/cometd/replay/36.0/1// Register streaming extension
2var replayExtension = new cometdReplayExtension();
3replayExtension.setChannel(<Streaming Channel to Subscribe to>);
4replayExtension.setReplay(<Event Replay Option>);
5cometd.registerExtension('myReplayExtensionName', replayExtension);After calling the setReplay() function on the extension, the events that the subscriber receives depend on the replay value parameter passed to setReplay().
Code Sample
For a code sample on how to replay generic streaming events, see Example: Replay Generic Streaming Events Using a Visualforce Page.