Salesforce Pub/Sub Source
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Preview"
Receives the events of a Salesforce channel, such as a Platform Event or the Change Data Capture events of a kind of record, through the Pub/Sub API, one message per event.
Use it to react to what happens in Salesforce, for example to an Order_Shipped__e Platform Event that a Flow publishes, or to every change of an account through /data/AccountChangeEvent. To be told about records that match a SOQL query, through a PushTopic, use salesforce-source.
Output: by default (deserializeType JSON) the body is the event as JSON text, with the fields of the event. The CamelSalesforcePubSubReplayId header holds the replay ID of the event, and CamelSalesforcePubSubEventId its ID.
Good to know: by default only the events published after the start are received. The Kamelet does not remember where it stopped: to go on after a restart, set replayPreset to CUSTOM and replayId to the replay ID of the last event processed.
Configuration Options
The following table summarizes the configuration options available for the salesforce-pubsub-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 | |||
Topic | Required The channel to subscribe to: | string | /event/BatchApexErrorEvent | ||
Authentication Type | How the Kamelet logs in. Enum values: * USERNAME_PASSWORD * CLIENT_CREDENTIALS * REFRESH_TOKEN * JWT | string | USERNAME_PASSWORD | ||
Batch Size | How many events to ask the Pub/Sub API for at a time. | integer | 100 | ||
Deserialize Type | What the body of each event is: Enum values: * AVRO * SPECIFIC_RECORD * GENERIC_RECORD * POJO * JSON | string | JSON | ||
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 | ||
Password | The password of | string | |||
POJO Class | The fully qualified name of the Java class to turn each event into. Only used when | string | com.example.events.OrderShipped | ||
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 | The replay ID of the last event already processed, as its | string | |||
Replay Preset | Where to start reading the channel: Enum values: * LATEST * EARLIEST * CUSTOM | string | LATEST | ||
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-pubsub-source Kamelet relies upon the presence of the following dependencies:
-
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-pubsub-source"
parameters:
.
.
.
steps:
- to:
uri: "kamelet:log-sink" You can now run it directly through the following command
camel run route.yaml Salesforce Pub/Sub Source Kamelet Description
Which API
This is the gRPC based Pub/Sub API, not the older streaming API that salesforce-source uses. Subscribe to a channel such as /event/MyEvent__e, /topic/MyTopic or /data/AccountChangeEvent.
Deserialization
deserializeType defaults to JSON so the body is JSON text, usable downstream without further decoding. The component’s own default is AVRO, which gives an Avro record object instead. Use POJO together with pojoClass to deserialise into a generated class.
Replay
By default (replayPreset set to LATEST) the Kamelet receives only the events published after it starts. Each event carries its replay ID in the CamelSalesforcePubSubReplayId header. To go on from a given event after a restart, set replayPreset to CUSTOM and replayId to the replay ID of the last event processed.
Runtime Dependency
The Pub/Sub API is gRPC based and needs a protobuf-java new enough for the generated stubs in camel-salesforce. Under Camel JBang an older protobuf is resolved and the route fails to start during class loading:
java.lang.NoClassDefFoundError: com/google/protobuf/RuntimeVersion$RuntimeDomain
Adding protobuf-java as an explicit dependency resolves it.