Salesforce Change Data Capture
Change Data Capture is a design pattern to determine and records changes to a record and take some action of changed data and keep your external data store current with Salesforce data.

Data integration to keep two systems synchronized in one of the following ways
- Have a data replication process to export data from source system and upload the data to the destination. Usually this type of process is run nightly as volume of data can be large. Changes are not reflected in near real time.
- Implement Change Data Capture pattern, this not only allows two systems to be in sync in near real time. also amount of data being shifted is less compared to option 1. In this pattern you are only concerned with record changes, including create, update, delete, and undelete operations.
Salesforce introduced Change Data Capture in Winter 19 GA. Change Data Capture is a streaming product on the Lightning Platform that allows to integrate efficiently with Salesforce data and external systems. Change Data Capture publishes events for changes in Salesforce records.
Use Change Data Capture to update data in an external system instead of doing periodic exports or API polling. Capturing changes with Change Data Capture event notifications ensures that your external data can be updated in real time and stays fresh.
Subscription channel naming convention , Salesforce follows following standard.
- Standard Object
- /data/ChangeEvent
- Example
- /data/CaseChangeEvent
- Custom Object
- /data/Custom_Object_Name__ChangeEvent
- Example (Employee__c )
- /data/Employee__ChangeEvent
In our example we configured Salesforce Change Data Capture and have MuleSoft flow subscribe to Change Data Capture(CDC) subscription channel.

Mule Configuration XML
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:sfdc="http://www.mulesoft.org/schema/mule/sfdc" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/sfdc http://www.mulesoft.org/schema/mule/sfdc/current/mule-sfdc.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
<sfdc:cached-basic-config name="Salesforce__Basic_Authentication" username="xxxxxx@xxxxx.xxx" password="xxxxxxxx" securityToken="xxxxxxxxxxxxxxxxxx" doc:name="Salesforce: Basic Authentication"/>
<flow name="sfdc-cdc-demoFlow">
<sfdc:replay-streaming-channel config-ref="Salesforce__Basic_Authentication" streamingChannel="/data/CaseChangeEvent" replayOption="ONLY_NEW" replayId="-1" doc:name="Salesforce (Streaming)" autoReplay="true"/>
<json:object-to-json-transformer mimeType="application/json" doc:name="Object to JSON"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
Steps to configure Change Data Capture can be found in reference links provided below.

Below is an example of change notification that is generated by Salesforce for an update to case record.
{
"schema": "GcQa-os7NZTWrXoNPPop0Q",
"payload": {
"Origin": "Web",
"LastModifiedDate": "2019-03-20T23:55:00Z",
"ChangeEventHeader": {
"isTransactionEnd": true,
"commitNumber": 10615467726738,
"commitUser": "005W0000002TRaFIAW",
"sequenceNumber": 1,
"entityName": "Case",
"changeType": "UPDATE",
"changeOrigin": "com/salesforce/api/soap/45.0;client=SfdcInternalAPI/",
"transactionKey": "0004770a-2640-81f8-a62f-1cf677f2b4ac",
"commitTimestamp": 1553126100000,
"recordIds": [
"500f4000005LDfSAAW"
]
}
},
"event": {
"replayId": 116021
}
}
Following is an Change Data event notification when new case is created.
{
"schema": "GcQa-os7NZTWrXoNPPop0Q",
"payload": {
"Origin": "Phone",
"PotentialLiability__c": "Yes",
"Status": "New",
"LastModifiedDate": "2019-03-20T23:57:20Z",
"AccountId": "001f400000MnROdAAN",
"Priority": "High",
"IsClosed": false,
"Reason": "Installation",
"Type": "Electronic",
"OwnerId": "005W0000002TRaFIAW",
"CreatedById": "005W0000002TRaFIAW",
"IsEscalated": false,
"SLAViolation__c": "No",
"ChangeEventHeader": {
"isTransactionEnd": true,
"commitNumber": 10615468700809,
"commitUser": "005W0000002TRaFIAW",
"sequenceNumber": 1,
"entityName": "Case",
"changeType": "CREATE",
"changeOrigin": "com/salesforce/api/soap/45.0;client=SfdcInternalAPI/",
"transactionKey": "0004772a-ca1c-018c-5f4c-bbee727ec244",
"commitTimestamp": 1553126240000,
"recordIds": [
"500f400000Fqi52AAB"
]
},
"CreatedDate": "2019-03-20T23:57:20Z",
"CaseNumber": "00001026",
"Product__c": "GC1040",
"Subject": "Seeking guidance on electrical wiring installation",
"LastModifiedById": "005W0000002TRaFIAW"
},
"event": {
"replayId": 116022
}
}
User subscribing to subscription channel need to have View All for the object OR View All Data permission of that Object.
If you Salesforce org is encrypted with Shield Platform Encryption then event notifications are blocked and aren’t delivered to subscription channel. To have notification delivered you would need to create Event Bus tenant secret on the Key Management page in Setup.
References
https://developer.salesforce.com/blogs/2018/08/what-is-change-data-capture.html
https://trailhead.salesforce.com/content/learn/modules/change-data-capture
https://developer.salesforce.com/events/webinars/change-data-capture
https://developer.salesforce.com/docs/atlas.en-us.change_data_capture.meta/change_data_capture/cdc_intro.htm