Salesforce Source
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Stable"
Receives an event each time a Salesforce record that matches a SOQL query is created, updated, deleted or undeleted, through a PushTopic of the Streaming API.
Use it to react to changes in Salesforce, for example to copy each new contact to a mailing tool or to alert a team when an opportunity is won. For Platform Events and Change Data Capture through the newer Pub/Sub API, use salesforce-pubsub-source.
Output: the body is the record as JSON text, with the fields that the query selects. The CamelSalesforceEventType header says what happened: created, updated, deleted or undeleted. The CamelSalesforceReplayId header identifies the event.
Good to know: when it starts, it creates the PushTopic topicName in Salesforce with query and the notify options, or updates it when it exists, so the user needs the permission to create PushTopics. By default only new records send an event; turn on notifyForOperationUpdate and the others for more. Only the events after the start are received, unless replayId is set.
Configuration Options
The following table summarizes the configuration options available for the salesforce-source Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
Consumer Key | Required The consumer key of the connected app that the Kamelet logs in through. In Salesforce Setup, open App Manager, choose View on the app, then Manage Consumer Details. | string | |||
Consumer Secret | Required The consumer secret of the same connected app, shown next to the consumer key under Manage Consumer Details. | string | |||
Query | Required The SOQL query of the PushTopic. It chooses the kind of record, the fields to send, and with an optional | string | SELECT Id, Name, Email, Phone FROM Contact | ||
Topic Name | Required The name of the PushTopic that the Kamelet creates or updates in Salesforce with | string | ContactTopic | ||
Authentication Type | How the Kamelet logs in. Enum values: * USERNAME_PASSWORD * CLIENT_CREDENTIALS * REFRESH_TOKEN * JWT | string | USERNAME_PASSWORD | ||
Instance URL | The address of your org, such as | string | https://myinstance.my.salesforce.com | ||
JWT Audience | The audience of the JWT that the Kamelet signs to log in: | string | https://login.salesforce.com | ||
Keystore | A reference to a bean of type | string | #bean:myKeystore | ||
Login URL | The address the Kamelet logs in to. Keep the default for a production org, use | string | https://test.salesforce.com | ||
Notify For Fields | Which changed fields make an update send an event: Enum values: * ALL * REFERENCED * SELECT * WHERE | string | ALL | ||
Notify Operation Create | If true, an event is sent when a record that matches | boolean | true | ||
Notify Operation Delete | If true, an event is sent when a record that matches | boolean | false | ||
Notify Operation Undelete | If true, an event is sent when a deleted record that matches | boolean | false | ||
Notify Operation Update | If true, an event is sent when a record that matches | boolean | false | ||
Operation | The kind of subscription of the Salesforce component. Leave it as | string | subscribe | ||
Password | The password of | string | |||
Raw Payload | If true, the record is passed on as the JSON text that Salesforce sent, instead of being read and written again. The body is JSON text either way. | boolean | false | ||
Refresh Token | A refresh token of the connected app for the user to act as, obtained once through an OAuth login in a browser with the | string | |||
Replay Id | Where to start: | long | |||
Username | The user name of the Salesforce user to log in as, which looks like an email address. Used by the | string |
Dependencies
At runtime, the salesforce-source Kamelet relies upon the presence of the following dependencies:
-
camel:jackson3
-
camel:salesforce
-
camel:kamelet
Camel JBang usage
Prerequisites
-
You’ve installed JBang.
-
You have executed the following command:
jbang app install camel@apache/camel Supposing you have a file named route.yaml with this content:
- route:
from:
uri: "kamelet:salesforce-source"
parameters:
.
.
.
steps:
- to:
uri: "kamelet:log-sink" You can now run it directly through the following command
camel run route.yaml Salesforce Source Kamelet Description
Authentication
This Kamelet logs in through a connected app of your org. You need to create a connected app in Salesforce and obtain its consumer key and consumer secret. authenticationType chooses how the Kamelet logs in: by default with userName and password.
How It Works
The Kamelet uses a PushTopic of the Salesforce Streaming API. When it starts, it creates the PushTopic named topicName with the SOQL query and the notify options, or updates it when it already exists. Salesforce then sends an event each time a record that matches the query is created, updated, deleted or undeleted, as the notify options choose. By default only new records send an event.
Configuration
The Salesforce Source Kamelet supports the following configurations:
-
Consumer Key (
clientId) and Consumer Secret (clientSecret): of the connected app (required) -
Username (
userName) and Password (password): the user to log in as, for the default authentication type -
Login URL (
loginUrl): Salesforce login URL (default: https://login.salesforce.com) -
Query (
query): the SOQL query of the PushTopic, which must selectId(required) -
Topic Name (
topicName): the name of the PushTopic (required) -
Notify options: which operations (
notifyForOperationCreate,notifyForOperationUpdate, …) and which fields (notifyForFields) send an event
Output Format
The Kamelet outputs each record as JSON text, with the fields that the query selects. The CamelSalesforceEventType header says what happened to the record: created, updated, deleted or undeleted.
Setup Requirements
-
Create a Connected App in Salesforce Setup
-
Configure OAuth settings and permissions
-
Obtain the consumer key and consumer secret
-
Generate or obtain the security token of the user, when needed
-
Ensure the user has API access and the permission to create PushTopics
Usage Example
- route:
from:
uri: "kamelet:salesforce-source"
parameters:
clientId: "{{salesforce.clientId}}"
clientSecret: "{{salesforce.clientSecret}}"
userName: "salesforce-user@example.com"
password: "{{salesforce.passwordAndToken}}"
topicName: "TechAccounts"
query: "SELECT Id, Name, Industry FROM Account WHERE Industry = 'Technology'"
steps:
- to:
uri: "kamelet:log-sink" Example with Custom Login URL and Updates
- route:
from:
uri: "kamelet:salesforce-source"
parameters:
clientId: "{{salesforce.clientId}}"
clientSecret: "{{salesforce.clientSecret}}"
userName: "salesforce-user@example.com"
password: "{{salesforce.passwordAndToken}}"
loginUrl: "https://test.salesforce.com"
topicName: "ContactChanges"
query: "SELECT Id, FirstName, LastName, Email FROM Contact"
notifyForOperationUpdate: true
steps:
- to:
uri: "kamelet:log-sink"