What is Change Data Capture?

Quick definition

Change Data Capture (CDC) in Salesforce is a native event-based mechanism that publishes real-time change events for Salesforce records (create, update, delete, undelete). CDC enables external systems and internal subscribers to receive a stream of record-level changes as Change Events so they can keep data synchronized, trigger processes, or audit changes without polling the database.

How it works

When CDC is enabled for an object, Salesforce generates a change event whenever a record on that object is created, updated, deleted, or undeleted. These events are exposed on channels in the Streaming API under the pattern:

/data/<ObjectName>ChangeEvent

Subscribers connect using a CometD client (e.g., the EMP Connector, Platform Events subscriber, or any CometD implementation) to receive JSON payloads describing the change.

Typical Change Event payload

Events include metadata (changeType, entityName, replayId) plus changed fields in a ChangeEvent structure. Example (trimmed):

{
"schema": "...",
"payload": {
"ChangeEventHeader": {
"entityName": "Account",
"changeType": "UPDATE",
"recordIds": ["001xx000003DGbYAAW"]
},
"Id": "001xx000003DGbYAAW",
"Name": "Acme Co",
"Industry": "Manufacturing"
}
}

Key features and benefits

– Real-time: delivers changes as they occur without polling.
– Reliable delivery: supports replay using replayId so subscribers can recover from outages.
– Field-level detail: event payloads include changed field values and ChangeEventHeader metadata.
– Declarative enablement: enable CDC for objects (standard and custom) in Setup without writing triggers.
– Schema evolution: event payloads follow a stable schema with versioning.

Common use cases

– Integrating Salesforce with external data stores (data warehouses, search indexes) and keeping them synchronized.
– Triggering downstream processes, ETL, or microservices on data changes.
– Auditing and compliance workflows that require a change log.
– Maintaining caches or denormalized views in other systems.

How to subscribe

Popular ways to receive CDC events:

  • EMP Connector (CometD) — common for Java-based listeners.
  • CometD clients in Node.js, Python, or Java.
  • Platform Events and Process Builder/Apex for in-org automation (Apex triggers can subscribe to change events).
  • Change Data Capture is available as event types under the Streaming API channels like /data/AccountChangeEvent.

Limitations & considerations

– Retention: change event messages are retained for a limited period — subscribers should use replayIds to avoid lost events.
– Field inclusion: only fields enabled in the object and supported field types are included; large blobs and some fields may be excluded.
– Event volume: high-frequency changes can generate large event volumes — architect for throughput and consumption limits.
– Ordering: per-entity ordering is generally preserved, but cross-entity ordering isn’t guaranteed.

Practical example: subscribe to Account change events (CometD)

// Subscribe to Account change channel
var channel = '/data/AccountChangeEvent';
// Connect with CometD, then subscribe to channel and process payload.payload.ChangeEventHeader

Conclusion

Salesforce Change Data Capture is a powerful, low-latency way to stream record changes to external systems and internal subscribers. It reduces the need for polling, provides reliable replay, and simplifies integration patterns for real-time synchronization and event-driven architectures.