Technology Blog Posts by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Swati_Singh
Product and Topic Expert
Product and Topic Expert
672

What is Salesforce Pub/Sub?

Salesforce is a SaaS Cloud solution offering integrated Marketing, Sales, Orders, and Support services. It centralizes customer data, automates processes, keeps information current, nurtures lead, and tracks marketing effectiveness.

The Salesforce Pub/Sub API allows for publishing and subscribing to platform events, including real-time monitoring and change data capture, supporting efficient event-driven architecture.

What is the Salesforce Adapter?

With the Salesforce Pub/Sub adapter, you have the capability to establish a connection with the Salesforce API and execute a variety of operations with different features.

Key Features

  • Allows you to subscribe to the channels to receive events.
  • Supports publishing of events to channels with defined schemas.
  • Retrieves schema from the Salesforce channel using the Get Schema operation.
  • Offers secure authentication options using OAuth 2.0 Username-Password and OAuth 2.0 JWT Bearer.
  • Using the Sender Adapter, you can retrieve events from a specific position (Custom)earliest position (Earliest), or latest position (Latest).
  • Provides an error-handling mechanism in case of subscription failure, allowing you to re-subscribe to the channel and retrieve events from the earliest position (Earliest) or latest position (Latest).

How does the adapter work?

The Salesforce Pub/Sub adapter is available as part of your SAP Integration Suite license.

To use the adapter, you must first add it to your Integration Flow, add the required Connection parameters, and configure it as per your Processing requirements. Once you have configured the Salesforce adapter, the SAP CI tenant enables data exchange at runtime by sending a request to the Salesforce receiver system.

Let’s demo the Publish operation using the Salesforce Pub/Sub Receiver Adapter.

Later on, we will learn how to read an event using Salesforce Pub/Sub Sender Adapter.

Publish an Event in Salesforce Pub/Sub Receiver Adapter

Our example illustrates how the Salesforce Pub/Sub Receiver Adapter allows to Publish an event to a channel.

Divij_Balguri09_6-1740393464561.png

 

Prepare Details in Content Modifier

In SAP Cloud Integration, Message Header, you can use a content modifier to prepare details and request payload that is required for Publishing an event.

Message Body contains the actual data payload, which is processed according to business requirements in the Salesforce Pub/Sub adapter.

Divij_Balguri09_7-1740393464565.png

Action

Name

Source Type

Source Value

Create

Channelname

Constant

/event/CPI_PubSub_Docs__e

Message Body
Divij_Balguri09_8-1740393464572.png

Connect to Salesforce Receiver Adapter

Divij_Balguri09_9-1740393464575.png

 

Parameter

Values

Host

Set as api.pubsub.salesforce.com

Port

Set value as 7442.

Tenant ID

Set as 00D300000008q58.

Authentication

Select the authentication type as OAuth 2.0 Username-Password from the dropdown.

Token URL

Set as https://test.salesforce.com for Salesforce Sandbox environment.

Credential Name

Set as SF_PubSub_CredentialName.

Security Token Alias

Set as SF_PubSub_SecurityToken.

OAuth Credential Name

Set as SF_PubSub_OAuthCredentialName.

 

Publish Event Using Salesforce Pub/Sub Receiver Adapter

To process details related to an event, you need to specify the operation as Publish and specify the Channel Name. This selection allows you to publish the events to the channel created in the Salesforce Pub/Sub.

Divij_Balguri09_10-1740393464577.png

The client system receives and interprets this response, adding and utilizing the events information as needed.

Read an Event Using Salesforce Pub/Sub Sender Adapter

After executing the publish operation, you can read the details related to the events. You can fetch numbers of events using the Channel Name created in the Salesforce Pub/Sub.

Divij_Balguri09_11-1740393464580.png

Connect for Salesforce Sender Adapter

Divij_Balguri09_12-1740393464583.png

 

Parameter

Values

Host

Set host as api.pubsub.salesforce.com

Port

Set value as 7442.

Tenant ID

Set value as 00D300000008q58.

Authentication

Select the OAuth 2.0 Username-Password from the dropdown.

Token URL

Set the URL as https://test.salesforce.com for Salesforce Sandbox environment.

Credential Name

Set as SF_PubSub_CredentialName.

Security Token Alias

Set as SF_PubSub_SecurityToken.

OAuth Credential Name

Set as SF_PubSub_OAuthCredentialName.

 Read Messages Using Salesforce Pub/Sub Sender Adapter

To retrieve details related to an event, you need to specify the Channel Name and select the Replay ID Approach as Events from the earliest position (Earliest) which allows the user to fetch earlier event messages stored in the event bus, Batch Size can be used to define the number of events needs to be fetched and Duplicate Check Expiration used to define the expiry time in millisecond. Now select the Replay Preset for Invalid Replay ID as Event from earliest position (Earliest) which allows user to fetch event from the event bus when replay ID are expired, corrupted or in case of an error. If Process Errors as an Event is enabled then, you will get the error messages as an exchange.

Divij_Balguri09_13-1740393464586.png

 

Parameter

Values

Channel Name

Set as /event/CPI_PubSub_Docs__e.

Replay ID Approach

Select the Events from earliest position (Earliest) from the dropdown.

Request Batch size

Set value as 100.

Replay Preset for Invalid Replay ID

Select the Events from earliest position (Earliest) from the dropdown.

Duplicate Check Expiration (in ms)

Set value as 300000.

Process Errors as an Event

Enable this property to write error events in the exchange. If disabled, issues connecting to event streams will only be written to the logs.

 

Quick Link

For detailed information about Salesforce Pub/Sub adapter configuration, see Salesforce Pub/Sub Adapter Documentation.

For detailed information about Salesforce Pub/Sub adapter, see Salesforce Pub/Sub Adapter for SAP Integration Suite.

Note: The Salesforce Pub/Sub Adapter is available as part of your SAP Integration Suite license.