Tutorials

  1. Home
  2. Dokumente
  3. Tutorials
  4. 120. Google Pub/Sub Adapter.
  5. 120.2 How to develop inbound interface to consume message from Google Pub/Sub topic?

120.2 How to develop inbound interface to consume message from Google Pub/Sub topic?

Learning Objectives:-

This unit describes:-

  • How to develop an Inbound interface to publish data into Google Pub/Sub topic?

Introduction:

In this tutorial, we will learn how the Google Pub/Sub adapter works for the Inbound interface to publish data into the Google Pub/Sub topic. This functionality is available from v2.47 onwards. In simple words, Google Pub/Sub adapter to publish data means Inbound google pub/sub Adapter. We need an Inbound Google Pub/SubAdapter when we want to send data out from salesforce, here We need to create a topic first. Then we can publish data into Google Pub/Sub topic.

So now we are going to check the use cases for Inbound google Pub/Sub Adapter i.e, for Publisher. To configure, firstly we need to learn and follow some steps:

Authorize Google App with Cloud Pub/Sub API and Get Access Token

Step1: Now we have to create a project in the Google developer console. So follow the below step to do that.

 

  • To create a new project we have to click on the “Create project link”.

  • Click on create button. Once the project is created we have to set credentials to our project. Follow the given steps to set credentials.
  • Click on the navigation menu.
  • Go to APIs& services.
  • Click credentials.

 

  • Click on create credentials button.

  • Select OAuth client Id from the list. Client ID: This is used to identify the application. … As per oAuth standard you need both Client ID & Client Secret along with user credentials to generate an access token. It’s the standard defined by OAuth.

 

  • Select Web application and give the name and click on create.

 

Authorization Scopes:

Requires one of the following OAuth scopes:

https://www.googleapis.com/auth/pubsub

https://www.googleapis.com/auth/cloud-platform

Step2: For oAuth2 authentication with Google API, we need to visit developers.google.com. We should click on Link: – https://developers.google.com/oauthplayground/. And Select Drive API v3 and click on Authorize API.

Note
We should have our Google account, If not then create a new Google account. Once we select drive API then authorize it with our Google account.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • When refresh token and Access token are generated then copy it and paste to notepad. (We need it later)

 

{

“access_token”: “ya29.a0AfH6SMB27Fc1tP6vIH7C5lswnK_J15tWMtGLaeb1bvbqQqYPBoRWT3gJbqkbhY8KsCag6tRJdyIJJADCFI3rrI9MmpxEAet2iM5nwiUhSABlQiDVcFsUYm5G9sZs40gsXU9XdDXRDAHzx_A1MRiXkjtWmNuiiwFM1lKzeHQ5Uew“,

“scope”: “https://www.googleapis.com/auth/pubsub https://www.googleapis.com/auth/cloud-platform”,

“token_type”: “Bearer”,

“expires_in”: 3599,

“refresh_token”: “1//04rm5yXZ6MX_vCgYIARAAGAQSNwF-L9IrgBSgkkKY8WQY2dfBYZ_txGpaSjPRs3hORqLnyrySgrgEmzmmK3nm-cGQ_I3ZbdZ_6Ug

}

Step 2: Enable API(Follow the link given below)

https://cloud.google.com/pubsub/docs/quickstart-client-libraries?authuser=1

  1. Set up a Cloud Console project.
  2. Set up a project
  3. Create or select a project.
  4. Enable the Pub/Sub API for that project.

 

5. Install and initialize the Cloud SDK.

Note
You can run the gcloud tool in the Cloud Console without installing the Cloud SDK. To run the gcloud tool in the Cloud Console, use Cloud Shell .

We can use Google cloud shell:

https://console.cloud.google.com/cloudpubsub/subscription/list?authuser=1&cloudshell=true&project=skyvva-278208

Quickstart using the gcloud command-line tool:

https://cloud.google.com/pubsub/docs/quickstart-cli

Step: 3 Create New Topic:

Example: gcloud pubsub topics create csvOutbound

  • Create New Subscription:
    Example: gcloud pubsub subscriptions create csvOutboundSub –topic csvOutbound.

Publish messages:

Publish a message to my-topic: gcloud pubsub topics publish my-topic –message=”hello”

Receive messages:

Receive the message from my-sub: gcloud pubsub subscriptions pull my-sub –auto-ack

Publish Messages:

Example: gcloud pubsub topics publish csvOutbound –message=”hello world”

Receive Messages:

Example: gcloud pubsub subscriptions pull csvOutboundSub –auto-ack

Step: 4 Create Metadata provider, Repository, and Message type(Pre-Requisite)

Step: 5 Create Integration(Pre-Requisite)

Step: 6 Create Inbound Adapter.

Step 7: Create Inbound Interface

Note
Adapter must be linked with only 1 inbound or 1 outbound interface.1 topic must be linked with only 1 subscription.

Integration: Google_Integration

Note
CSV, JSON, and XML Inbound Examples: In Inbound case, we are sending data from Google pub/sub server side to Salesforce.

CSV Inbound Case:

Inbound Interface Name: Cloud_Pub_Sub_CSV_IB

Inbound Adapter Name: Google Cloud Pub/Sub CSV IB

Message Monitoring:

XML Inbound Case:

Inbound Interface Name: Cloud_Pub_Sub_XML_With_NP_IB

Inbound Adapter Name: Google Cloud Pub/Sub XML IB

Message Monitoring:

JSON Inbound Case:

Inbound Interface Name: Cloud_Pub_Sub_JSON_IB

Inbound Adapter Name: Google Cloud Pub/Sub JSON IB

Message Monitoring:

 

 

Fandest du diesen Artikel hilfreich? Ja Nein

Wie können wir helfen?