Software AG Products 10.7 | Integrating On-Premises and Cloud Applications | Administering CloudStreams | webMethods CloudStreams Documentation | Administering webMethods CloudStreams | Cloud Connections, Services, and Connector Listeners | Replaying Salesforce events
 
Replaying Salesforce events
CloudStreams connector provides a near real-time integration with Salesforce by leveraging their Streaming APIs based on Bayeux protocol and CometD. The underlying communication is based on long polling where the connector listener establishes 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 Salesforce events for a Cloudstreams connector listener by specifying the Replay Options using the CloudStreams Administration console in Integration Server Administrator.
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.
LAST-RECEIVED
Receive all the events after the last received event by CloudStreams within the retention window. This configuration is helpful especially in cases such as sudden missing events due to a network failure or any other unexpected error.
For example, if the connector listener subscription is active, and a temporary network disruption can cause a loss of events. However, if you have configured the connector listener with this option then the missing events are automatically replayed as soon as the connectivity is restored with a replay id that was last received by CloudStreams before the network failure.
CUSTOM
Receive all the events specified by a replayId computed by a custom service. You can store and compute the replayIds of the past events. This option lets you point to any replay id in the old event stream. You must write a custom service adhering to wm.cloudstreams.listener.metadata.connection.specs:retrieveReplayIDSpec and it must map the replayId to computedReplayID key. This service must be provided in the Retrieve Replay ID Service field. The configured service is executed that is subscribing to Salesforce Streaming API and the value of the computedReplayID is used to specify the replayId during subscription.
Note:
Currently, the replay options are supported only for Salesforce Push Topic.
*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.
*LAST-RECEIVED- To replay all the events after the event that was last received by CloudStreams, within the retention window.
*CUSTOM- To replay the events after the event specified by a replayId that is computed by a custom service. The customized service is provided in the Retrieve ReplayID Service field.
7. Click Enable
While enabling the listener, you can choose to provide a replayId in the Specify ReplayID field. This is an optional field. If you provide the replayId in this field, then all the events past that replayId will be replayed and the action cannot be undone. This input replayId overrides all the other configurations. If you choose to ignore this field, then the replayId derived from the Replay Option setting will take effect. Additionally, this replayId can only be tracked as part of auditing or logging as it is not stored within CloudStreams.