Salesforce Pub/Sub API

Subscribe to and publish Salesforce platform events and Change Data Capture events via the gRPC-based Pub/Sub API.

Subscribe

- salesforce_pubsubapi_subscribe:
    name: account_changes
    credentials_path: /etc/salesforce/credentials.json
    topic:
      name: /data/AccountChangeEvent
      num_requested: 100
      durable_consumer_options:
        enabled: true
        managed_subscription: true
        name: flowgen_account_sub
        replay_preset: latest

Subscriber fields

FieldTypeDefaultDescription
namestringrequiredTask name.
credentials_pathstringrequiredPath to Salesforce credentials.
topic.namestringrequiredTopic name (e.g., /data/AccountChangeEvent).
topic.num_requestedint100Events per batch, 1 to 100.
topic.durable_consumer_optionsobjectDurable consumer settings (see below).
endpointstringCustom Pub/Sub API endpoint.
ack_timeoutdurationwait indefinitelyHow long to wait for the flow to complete an event.
max_deliverintHow many times an event is sent through the flow before it is skipped. When omitted, an event is delivered until the flow completes it.
depends_onlistUpstream task names.
retryobjectRetry configuration for connecting and for redelivery.

Delivery

Batches run through the flow one at a time, in order; the events of a batch run concurrently. When a batch starts, the subscriber asks Salesforce for the next num_requested events, so at most one batch waits. Salesforce closes a stream that has no requested events outstanding for 60 seconds, so while a batch waits longer than 30 seconds the subscriber asks for one more event at a time.

An event the flow fails to complete, or does not complete within ack_timeout, is delivered again after the redelivery delay, and the next batch waits for it. With max_deliver, the event is skipped after that many failed deliveries and logged with its event ID.

When a batch is done, a durable consumer stores the replay ID of its last event: a managed subscription commits it to Salesforce, otherwise it is kept in the flowgen cache. On a quiet topic it also stores the latest replay ID from Salesforce keepalives once every batch is done, so the stored position stays within the retention window. After a restart, reading continues after it. Delivery is at least once.

A cached replay ID that Salesforce rejects as invalid is deleted, and the next subscription starts from replay_preset.

When the stream breaks, the subscriber reconnects with the reconnect backoff. The delay resets to initial_backoff once the new stream delivers a response, so a subscription that fails before its first response, such as one without access to the topic, keeps backing off.

Durable consumer options

FieldTypeDefaultDescription
enabledboolrequiredEnable durable consumer.
managed_subscriptionboolSalesforce manages the subscription lifecycle.
namestringrequiredConsumer name.
replay_presetstringlatestStart position: latest or earliest.

Publish

- salesforce_pubsubapi_publish:
    name: publish_event
    credentials_path: /etc/salesforce/credentials.json
    topic: /event/Order_Update__e
    payload:
      Order_Id__c: "{{event.data.order_id}}"
      Status__c: "{{event.data.status}}"

Publisher fields

FieldTypeDefaultDescription
namestringrequiredTask name.
credentials_pathstringrequiredPath to Salesforce credentials.
topicstringrequiredTarget topic name.
payloadobjectrequiredEvent payload — explicit fields or from_event: true.
endpointstringCustom Pub/Sub API endpoint.
depends_onlistUpstream task names.
retryobjectRetry configuration.

Output

FormatCrateDescription
Avrosalesforce_coreAvro-decoded event payload as defined by the Salesforce event schema. CDC events include change data and change descriptor. Event ID is set as event.id.