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
467

In many integration scenarios, messages must be exchanged between applications or systems. The Google Pub/Sub adapter is a Cloud Integration capability available on SAP Integration Suite that facilitates message publishing and subscription service.

You can use Google Pub/Sub Adapter in your message-based integration solutions with ease. 

Introduction to Google Pub/Sub 

Google Pub/Sub works as a messaging middleware for traditional service integration or a simple communication medium for modern microservices.

Key Benefits of using Google Pub/Sub Adapter 

Google Pub/Sub Adapter has the following features:  

  • The receiver adapter allows reliable publishing of messages to Google Pub/Sub. It offers single message (Basic) and multiple message publishing (Advanced) capabilities.
  • Support for listing Topics with pagination using Page Token.
  • Allows you to modify the acknowledgement deadline of a message using the Modify Acknowledgement Deadline operation.
  • The sender adapter allows consuming messages from Google Pub/Sub. You can read messages in real time (gRPC) or using a specified polling interval (REST). 
  • Provides multiple post-processing options: Acknowledge after Successful Processing, Acknowledge Immediately, and Do not Acknowledge.
  • Offers secure authentication via OAuth2 Service Account option which uses Key Pair authentication.

How to use the Google Pub/Sub Adapter? 

You can publish messages using Topics or you can read messages from a subscription. 

In this blog, let us look at the Publish Message operation using the Topics entity. 

Publish a Message using Google PubSub Adapter 

A sample of the integration flow is shown in the figure below. 

ashishkuvvarapu_0-1739261893515.png

Prepare Message Details using Content Modifier 

We use a Content Modifier to store the connection details like private key alias and email. Also message topic and subscription details like Topic ID, Project ID can be saved here. 

ashishkuvvarapu_1-1739261973283.png

Message body stores the message to be published. 

ashishkuvvarapu_2-1739262018763.png

Connect to Google PubSub Adapter 

The Connection tab contains connection and authentication parameters for Google Pub/Sub. 

ashishkuvvarapu_3-1739262054118.png

The Connection tab contains the following fields:

Parameter 

Description 

Address 

Specify the hostname pointing to the Google Pub/Sub service.

Default: https://pubsub.googleapis.com 

Authentication Type 

Select the method for authentication to Google Pub/Sub. Currently OAuth2 Service Account is supported. 

OAuth2 Token URL 

Specify the OAuth2 Token URL which identifies as the authorization server for producing a JWT token internally.

Default: https://www.googleapis.com/oauth2/v4/token 

Client Email 

Specify the Google Service Account Client Email.

Example: limited-svc-account@192843.iam.gserviceaccount.com 

Private Key Alias 

Specify the Google Service Account Private Key for authentication. 

Scope 

Specify the scope of the connection to Google Pub/Sub service.

Default: pubsub 

Reuse Connection 

Enable the reuse of connection objects from the internal connection pool which in turn improves the network turnaround time for multiple communications to the same end point.

Connection Timeout (in ms) 

Specify the maximum waiting time (in milliseconds) for the connection to be established with Google Pub/Sub service. 

Response Timeout (in ms) 

Specify the maximum waiting time (in milliseconds) for a response message to be received with Google Pub/Sub service. 

 

Publish Message using Google PubSub Adapter  

Now switch to Processing, to perform the Publish Message operation. 

ashishkuvvarapu_4-1739262209577.png

Parameter 

Description 

Entity 

Select the entity for message processing: 

  • Topics 
  • Subscriptions 

Operation 

Select the operation to be performed. 

Project ID 

Specify the Google Pub/Sub project ID. 

Topic ID 

Specify the Topic ID to be used. 

Operation Type 

Select the type of operation when Operation is set to Publish Message. 

Encode Data 

Enable to encode data to Base64.

Note: Google Pub/Sub can only accept Base64 encoded data. If not enabled data must be converted to Base64 before using the adapter. 

Ordering Key 

Specify the ordering key for this message.

Note: For subscriptions with message ordering enabled, messages with the same ordering key are sent in the order in which they were published. 

Subscription ID 

Specify the Subscription ID. 

Acknowledgement ID 

Specify the Acknowledgement ID for the messages being used. 

Acknowledgement Deadline (in sec) 

Specify the new acknowledgement deadline with respect to the time when this request is sent to the Google Pub/Sub system. 

Page Size 

Specify the maximum number of topics to be returned.

Example: 10 

Page Token 

Specify the value returned by the last ListTopicsResponse; indicates that this is a continuation of a prior topics.list call, and that the system should return the next page of data.

Message Attributes 

Specify multiple message attributes as key value pairs.

Example:  Set Key to status and Value to end_of_message 

Verify message in Google PubSub topic 

Once you have a subscription set up to consume messages from your topic. You can see the below message when you PULL messages on the Google PubSub application. 

98231231,John Doe,20 

Quick Links 

For detailed information about Google Pub/Sub adapter configuration, see Google PubSub Adapter Guide and Google PubSub Help. 

Note: The Google PubSub Adapter is available as part of your SAP Integration Suite license.