Sub topic 1
What Change Data Capture Is and When to Use It
Prerequisites
You should know Salesforce objects, records, and fields. You should also understand basic publish/subscribe messaging, where publishers send messages and subscribers receive them. Basic Apex and JSON knowledge will help with later chapters.
What Change Data Capture Does
Change Data Capture (CDC) publishes an event when a selected Salesforce record is created, updated, deleted, or undeleted. The event contains metadata about the change and, for updates, the fields that changed. Subscribers can use the event to update another system without repeatedly querying Salesforce.
CDC is useful for near-real-time integrations, data warehouses, search indexes, and caches. It differs from polling because the subscriber waits for notifications instead of checking for changes on a schedule. PushTopic provides filtered notifications for selected fields and records, but CDC is designed to describe record changes broadly. Platform events carry business messages that your application defines; CDC events are generated from Salesforce record changes.
The Event Bus and Publish/Subscribe
Salesforce publishes CDC events to the event bus, a managed stream of event messages. A channel identifies the stream that subscribers listen to. Multiple subscribers can receive the same event independently.
This separation reduces coupling. Salesforce does not need to know whether a subscriber is an Apex trigger, Lightning Web Component, or external client.
Enabling CDC for Objects
In Setup, open Data Capture and select Change Data Capture. Move the standard or custom objects whose changes you want to publish into the selected list, then save.
Enable only the objects required by the integration. Publishing more objects increases event volume and may consume allocation capacity. For a custom object, select its object name in Data Capture just as you would select a standard object.
Channel Names for Change Events
A standard or custom object uses this channel pattern:
| Object | CDC channel |
|---|---|
| Account | `/data/AccountChangeEvent` |
| Invoice__c | `/data/Invoice__ChangeEvent` |
The custom object’s API name ends in __c; its change-event channel replaces that ending with __ChangeEvent. A subscriber must use the exact API name and capitalization.
Exercise
What channel should a subscriber use for the custom object Order__c?
Show answer
/data/Order__ChangeEvent.