Streaming, Platform Events and CDC
This page is not fully complete
Overview
Terms
https://developer.salesforce.com/docs/atlas.en-us.224.0.api_streaming.meta/api_streaming/terms.htm
Pub / Sub
Bayeux Protocol, CometD, and Long Polling
CometD client
If the client receives events, the client must reconnect immediately using CometD to receive the next set of events. If the reconnection doesn't occur within 40 seconds, the server expires the subscription, and the connection closes.
The maximum size of the HTTP request post body that the server can accept from the client is 32,768 bytes.
Streaming API
Push technology - Pub / Sub model
Near real-time stream of data, but asynchronous
Can be used internally also
Active connection must be maintained via long polling
Steps
Push Topics are created
Client negotiates a connection
Login request and response
Handshake request
Connection request
Subscribe to a channel
Client waits for an event
No need for polling
Salesforce Broadcast changes
Client asks Salesforce to keep the connection open
Concurrent limits (No. of long running calls) and total limits.
Streaming API regularly validates the OAuth token or session ID while the client is connected.
Durability is not guaranteed
Change Data Capture
With Change Data Capture, you can receive changes of Salesforce records in real time and synchronize corresponding records in an external data store.
Receive auto-published event notifications for Salesforce record changes
Change Data Capture publishes events for changes in Salesforce records corresponding to create, update, delete, and undelete operations.
The order of the fields in the JSON event message is not guaranteed.
Standard or Custom Channels
Single entity or multiple entities
Create a custom channel if you have multiple subscribers and each subscriber receives change events from a different set of entities.
Change Data Capture ignores sharing settings and sends change events for all records of a Salesforce object.
To use CDC on Task and Event the external user must have View All Data to your entire system. Don’t do this! The External user must have View All for the object that is being tracked. See extra notes on permissions https://developer.salesforce.com/docs/atlas.en-us.change_data_capture.meta/change_data_capture/cdc_security_perms.htm
See notes for encryption https://developer.salesforce.com/docs/atlas.en-us.change_data_capture.meta/change_data_capture/cdc_security_shield_encryption.htm