Replaying Salesforce events
CloudStreams connector listeners can subscribe to any streaming provider and listen to subscribed events. This allows CloudStreams connector listeners to establish a persistent connection with the Salesforce provider. This connection remains open while transmitting the events until either side closes the connection. Through this established connection, events are streamed to the listener. If the connection is lost due to a network failure or any other reason, you can retrieve the standard-volume events that are within Salesforce's 24-hour retention window.
Note: You can retrieve Salesforce events only if you are using Salesforce v37.0 or later and CloudStreams v10.3 or later.
Each Salesforce event is assigned an opaque ID which is unique for each event. This ID is contained in the replayId field of the event object. The replayId field value which is populated by Salesforce when the event is delivered to subscribers, refers to the position of the event in the event stream. For consecutive events, replayId values may have a break between them, for example, the event with ID 110 may follow the event with ID 101.
Example of an event object that Salesforce sends to its subscribed clients
{
"clientId":"a1ps4wpe52qytvcvbsko09tapc",
"data":{
"event":{
"createdDate":"2016-03-29T19:05:28.334Z",
"replayId":55
},
"payload":"This is a message."
},
"channel":"/u/TestStreaming"
}
To replay events, Salesforce provides a way to configure the replayId while subscribing to a particular channel. You can replay the lost events by specifying the Replay Options and can use it on a resubscription, to retrieve events that are within the retention window.
Replay Option (replayId) | Usage |
NEW (-1) | Receive new events that are broadcast after the client subscribes. |
ALL (-2) | Receive all events including past events that are within the retention window including new events. |
Note: Currently, only Salesforce Push Topic is supported for replay options.
To replay Salesforce events
1. Go to Integration Server Administrator > Solutions > CloudStreams > Providers.
2. Select the Salesforce.com provider to list all the connectors.
3. Click on the connector for which you have already created a listener.
4. Go to the Listener page and disable the Salesforce connector listener for which you want to configure the replay option.
5. Click Configure.
6. In the Replay Options field, choose:
ALL - To replay all the events for the last 24 hours.
NEW - To replay only the new events from the time the connector listener is enabled.