The example provides REST API endpoints for managing Salesforce contacts (list all, get by ID, update) and implements real-time monitoring of Contact changes through Change Data Capture (CDC) events.
-
REST API endpoints to fetch all Salesforce contacts, get contact by ID and update a contact by ID
-
Listens continuously for Change Data Capture events (CDC)
-
Salesforce authentication using client credentials flow
-
Java 17 or higher
-
Maven 3.6+
-
Salesforce developer account
-
Salesforce Connected App credentials
-
Create a Connected App in your Salesforce org:
-
Go to Setup > Apps > App Manager > New Connected App
-
Enable OAuth Settings
-
Set Callback URL (can be http://localhost:8080)
-
Add 'Perform requests at any time' to Selected OAuth Scopes
-
Save and wait for activation
-
-
Enable CDC events for Contact object:
-
Go to Setup > Integrations > Change Data Capture
-
Add
Contact (Contact)
to Selected Entities -
Save
-
-
Copy
src/main/resources/application.properties.example
tosrc/main/resources/application.properties
-
Update the properties with your Connected App credentials:
camel.component.salesforce.client-id=<YOUR_CLIENT_ID> # Consumer Key from Connected App camel.component.salesforce.client-secret=<YOUR_CLIENT_SECRET> # Consumer Secret from Connected App camel.component.salesforce.instance-url=<YOUR_DOMAIN> # e.g. https://your-org.my.salesforce.com camel.component.salesforce.login-url=<YOUR_DOMAIN> # Same as instance-url
-
Fetch all contacts:
curl -X GET http://localhost:8080/camel/contacts | jq
-
Fetch a specific contact:
curl -X GET http://localhost:8080/camel/contacts/003XXXXXXXXXXXXXXX | jq
Replace 003XXXXXXXXXXXXXXX
with an actual Salesforce Contact ID.
-
Update a specific contact:
curl --location --request PUT 'http://localhost:8080/camel/contacts/003XXXXXXXXXXXXXXX' \ --header 'Content-Type: application/json' \ --data-raw '{ "LastName": "Smith", "FirstName": "John", "Salutation": "Mr.", "Email": "[email protected]", "Description": "Test description" }'
Replace 003XXXXXXXXXXXXXXX
with an actual Salesforce Contact ID.
Listens continuously for Contact Change Events (CDC):
-
Make changes to contacts in Salesforce or update a specific contact
-
Watch the application logs for real-time change events