Salesforce Inbound Endpoint CDC (Change Data Capture) Example¶ About Change Data Capture (CDC)¶ Change Data Capture (CDC) in Salesforce allows you to receive real-time changes of Salesforce records, including record creation, updates, deletions, and undeletions. Unlike PushTopics, CDC supports a broader set of standard and custom objects, and it's more scalable and recommended for enterprise-grade integrations. CDC events are published to event channels in the format: /data/<ObjectName>ChangeEvent. These events can be consumed by WSO2 Integrator: MI through a Salesforce Inbound Endpoint. What you'll build¶ This guide shows how to configure a Salesforce Inbound Endpoint using CDC to listen to real-time changes in the Account object. You will: Enable CDC for a Salesforce object. Set up Salesforce authentication (username/password or OAuth2 Client Credentials). Configure the Inbound Endpoint in WSO2 Integrator: MI using the Visual Studio Code extension. Run and test the integration to receive real-time events. The inbound endpoint captures CDC events and injects them into a mediation sequence. In this example, we simply log the message, but you can extend it with any logic using WSO2 Integrator: MI mediators. Step 1: Enable CDC for the Account Object¶ Login to your Salesforce Account. On the Home page, click the Setup icon (top right). In the Quick Find box, search for Change Data Capture. Click Change Data Capture under the Integrations section. Select the Account object (or any other object you'd like to track) and click Save. This enables the publication of AccountChangeEvent events. Step 2: Set up Salesforce Authentication¶ The Salesforce Inbound Endpoint supports two authentication methods: Username/Password (username-token) — authenticates using a Salesforce username, password, and security token via the SOAP login API. This is the default authentication type. OAuth2 Client Credentials (oauth) — authenticates using a Salesforce Connected App's consumer key and secret via the OAuth2 Client Credentials grant. Recommended for server-to-server integrations where storing a user password is undesirable. Version requirement OAuth2 Client Credentials authentication is available from Salesforce Inbound Endpoin version 3.0.5 onwards. Choose the authentication method that fits your deployment. Username/Password (username-token)OAuth2 Client Credentials (oauth) Login to Salesforce. Click the User Settings icon → Settings. Navigate to Reset My Security Token and click Reset Security Token. You will receive the new security token via email. You will need to append it to your password when configuring the inbound endpoint. Create a Salesforce External Client App that supports the Client Credentials flow: Login to your Salesforce Account and click the Setup icon (top right). In the Quick Find box, search for External Client App Manager (under External Client Apps) and open it. Alternatively, go to App Manager (under Apps) and click the New External Client App button in the top right. Click New External Client App. Enter an App Name and a Contact Email Address. Under OAuth Settings, enable Enable OAuth and configure the following: Callback URL: Enter any valid URL (e.g., https://login.salesforce.com/services/oauth2/success). Selected OAuth Scopes: Add Manage user data via APIs (api) and any other required scopes. Enable Enable Client Credentials Flow. Click Create. After saving, open the app, go to the Settings tab, and click Consumer Key and Secret to retrieve the Consumer Key (clientId) and Consumer Secret (clientSecret). To assign a run-as user for the Client Credentials flow, go to the app's Policies tab, click Edit, and set the Run As username to a dedicated integration user. Note The Client Credentials flow does not require end-user interaction and is intended for server-to-server integrations. Use a dedicated integration user with the minimum required permissions as the run-as user. Step 3: Configure Salesforce Inbound Endpoint (CDC) in VS Code¶ Follow Create Integration Project to create your integration project. Under Add Artifact, choose Event Integration. Select Salesforce Inbound Endpoint. Fill in the form with the values for your chosen authentication method: Username/Password (username-token)OAuth2 Client Credentials (oauth) Name: SalesforceCDCInboundEP Injecting Sequence Name: test Error Sequence Name: test Polling Interval: 100 Salesforce Object: /data/AccountChangeEvent Package Version: 45.0 Authentication Type: username-token User Name: <USERNAME> Password: <PASSWORD><SECURITY_TOKEN> Login Endpoint: https://login.salesforce.com SOAP API Version: 45.0 Wait Time: 5000 Connection Timeout: 20000 Execute sequentially and Coordination: select Replay: deselect Event ID File Path: <FILE_PATH> Name: SalesforceCDCInboundEP Injecting Sequence Name: test Error Sequence Name: test Polling Interval: 100 Salesforce Object: /data/AccountChangeEvent Package Version: 45.0 Authentication Type: oauth Client ID: <CONSUMER_KEY> Client Secret: <CONSUMER_SECRET> Token Endpoint: https://login.salesforce.com/services/oauth2/token (use https://test.salesforce.com/services/oauth2/token for sandboxes) Wait Time: 5000 Connection Timeout: 20000 Execute sequentially and Coordination: select Replay: deselect Event ID File Path: <FILE_PATH> Note When using OAuth2 Client Credentials, the User Name, Password, and Login Endpoint fields are not required and will be ignored if provided. Add a Log Mediator to print the incoming CDC event: Add a Drop Mediator to discard the message after logging: Step 4: Deploy, Run and Test the Integration¶ Run the Integration¶ Build and run the integration using the Deploy Artifacts Guide or simply click the Run button in VS Code extension to run the integration. Test the CDC Event Flow¶ Go to your Salesforce account and Go to the Accounts tab. Select any account and click on edit to update the account details. Expected Output¶ After updating an account, you should see logs like the following in the WSO2 Integrator: MI console: To: , MessageID: urn:uuid:56B8EFA309A76212999999737229929, Direction: request, Payload: {"event":{"replayId":6,"createdDate":"2024-12-01T14:21:45.458Z"},"payload":{"ChangeEventHeader":{"entityName":"Account","changeType":"UPDATE"},"Name":"Updated Account","Id":"0012x000005Xc9ZAAS"}}