---
title: Google Cloud Pub/Sub
slug: bhdo/google-cloud-pubsub
createdAt: 2022-11-24T18:24:54.000Z
---

You can integrate Belden Horizon Data Operations with the [Google Pub/Sub service](https://cloud.google.com/pubsub/docs/overview). This set of instructions shows you how to create a Google Pub/Sub connector and use it for:

- Publishing data from a topic in your edge device to a *Subscription&#x20;*&#x74;opic in the Google Cloud Platform
- Subscribing to data published by a *Publication&#x20;*&#x74;opic in the Google Cloud Platform

# Before You Begin

You need to create a Google Service Account.

# Set up the Outbound Connection (Publish to Google Pub/Sub)

Follow the steps below to set up the outbound connection.&#x20;

## Step 1: Create Publication Topic in Google Cloud Platform

In the Google Cloud Platform, create a *publication&#x20;*&#x74;opic. A matching *subscription&#x20;*&#x74;opic is created automatically, with the *-sub* suffix appended to the topic name.

## Step 2: Add Device

Follow the steps to [Connect a Device](https://public-docs.litmus.io/bhdo/connect-a-device). The device will be used to store tags that will be eventually used to create outbound topics in the connector. Make sure to select the **Enable Data Store** check box.&#x20;

## Step 3: Add Tags

After connecting the device in Belden Horizon Data Operations, you can [Add Tags](https://public-docs.litmus.io/bhdo/add-tags) to the device. Create tags that you want to use to create outbound topics for the connector.&#x20;

## Step 4: Add Connector

Follow the steps to [Add a Connector](https://public-docs.litmus.io/bhdo/add-a-connector) and select the **Google Cloud Pub/Sub Connector** provider.&#x20;

Configure the following parameters.&#x20;

- **Name**: A recognizable name to identify the connector.&#x20;
- **Service Account Key (.json)**: Copy the JSON key from your Google Cloud Platform and paste it here.&#x20;
- **The project ID of the cloud project**: Copy the ID from your Google Cloud Platform and paste it here.&#x20;
- **Integration Topic**: Copy the name of the *Publication&#x20;*&#x74;opic (without the "-sub" suffix) from your Google Cloud Platform and paste it here.
- **Parallel Publish Count**: The number of messages being published simultaneously. The default value is **100**. &#x20;
- **Parallel byte threshold**: The minimum size of a batch (in bytes) for the batch to be published. The default value is zero, which means that there is no threshold (limit).&#x20;
- **Publish count threshold**: The minimum number of messages in a batch for the batch to be published. The default value is zero, which means that there is no threshold (limit).&#x20;
- **Publish delay threshold (Milliseconds)**: The maximum time that the client will attempt to publish a batch of messages. The default value is zero, which means that there is no threshold (limit).&#x20;
- **Throttling limit**: The maximum number of messages per second to be processed. The default value is zero, which means that there is no limit.&#x20;
- **Persistent storage**: When enabled, this will cause messages to undergo a store-and-forward procedure. Messages will be stored within Belden Horizon Data Operations when cloud providers are online. &#x20;

## Step 5: Enable the Google Cloud Connector

**To enable the connector:&#x20;**

1. Return to the *Belden Horizon Data Operations Integration* browser tab.
2. Click the connection toggle on the connector tile.&#x20;
   The connector shows connected after verifying the connection.

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/OKO2FqrmWZAqm2HyHCrgQ_googlecloud.png" size="60" width="344" height="253" caption="Toggle to enable connector" position="center" showCaption="true"}

## Step 6: Create Outbound Topics for Google Cloud Connector

You will now need to import the tags you added in Step 2 to the connector as topics.&#x20;

**To create outbound topics:**

1. Click the connector tile.
   The connector *Dashboard&#x20;*&#x61;ppears.&#x20;
2. Click the **Topics&#x20;**&#x74;ab.&#x20;
3. Click the **Import from DeviceHub** tags icon.&#x20;
   The *DeviceHub Import&#x20;*&#x64;ialog box appears.

   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/4fC8yaOKctxiiTvUDGfWu_import-from-devicehub.png" size="80" width="1148" height="570" position="center" showCaption="false"}
4. Select all the tags to import and click **Import**.&#x20;

After importing the tag(s), do the following:

- Edit the tag and configure the **Remote Data Topic**. Copy and paste the name of the *Subscription&#x20;*&#x74;opic  (with the` -sub` suffix) from your Google Cloud Platform. &#x20;
- Make sure the connector has a CONNECTED status.&#x20;

## Step 7: Enable Topics

Because you imported DeviceHub tags for a *CONNECTED* connector, all topics will be disabled.&#x20;

To enable the topics, return to the Topics tab and click the **Enable all topics** icon.&#x20;

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/Bgs6D9yH8dU8qzJycO9lv_enable-all-topics.png" size="80" width="1148" height="570" caption="Enable all topics icon" position="center" showCaption="true"}

## Step 8: Verify Connection in Google Cloud Platform

**To verify the connection in Google Cloud Platform:**

1. Pull the *subscription&#x20;*&#x74;opic to see messages it receives from the Belden Horizon Data Operations outbound topics created previously.&#x20;

   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/-VdXPYXn3ue8QmzOVGPMD_pubsubmsg1000x272.png" size="80" width="1000" height="272" caption="List of Belden Horizon Data Operations outbound topics" position="center" showCaption="true"}
2. View the *subscription&#x20;*&#x73;tatistics.&#x20;

   ![](https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/u-2c_cHty2BoX6BGFJBKN_pubsubgraph1000x235.png "Graph of subscription statistic")

# Set up the Inbound Connection (Subscribe to Google Pub/Sub)

Follow the steps below to set up the inbound connection.&#x20;

## Step 1: Create Publication Topic in Google Cloud Platform

In the Google Cloud Platform, create a *publication&#x20;*&#x74;opic.

## Step 2: Add Device

Follow the steps to [Connect a Device](https://public-docs.litmus.io/bhdo/connect-a-device). The device will be used to store tags that will be eventually used to create outbound topics in the connector. Make sure to select the **Enable Data Store** check box.&#x20;

## Step 3: Add Tags

After connecting the device in Belden Horizon Data Operations, you can [Add Tags](https://public-docs.litmus.io/bhdo/add-tags) to the device. Create tags that you want to use to create outbound topics for the connector.&#x20;

## Step 4: Add Connector

Follow the steps to [Add a Connector](https://public-docs.litmus.io/bhdo/add-a-connector) and select the **Google Cloud Pub/Sub Connector** provider.&#x20;

Configure the following parameters.&#x20;

- **Name**: A recognizable name to identify the connector.&#x20;
- **Service Account Key (.json)**: Copy the JSON key from your Google Cloud Platform and paste it here.&#x20;
- **The project ID of the cloud project**: Copy the ID from your Google Cloud Platform and paste it here.&#x20;
- **Integration Topic**: Copy the name of the *Publication&#x20;*&#x74;opic from your Google Cloud Platform and paste it here.
- **Parallel Publish Count**: The number of messages being published simultaneously. The default value is **100**. &#x20;
- **Parallel byte threshold**: The minimum size of a batch (in bytes) for the batch to be published. The default value is zero, which means that there is no threshold (limit).&#x20;
- **Publish count threshold**: The minimum number of messages in a batch for the batch to be published. The default value is zero, which means that there is no threshold (limit).&#x20;
- **Publish delay threshold (Milliseconds)**: The maximum time that the client will attempt to publish a batch of messages. The default value is zero, which means that there is no threshold (limit).&#x20;
- **Throttling limit**: The maximum number of messages per second to be processed. The default value is zero, which means that there is no limit.&#x20;
- **Persistent storage**: When enabled, this will cause messages to undergo a store-and-forward procedure. Messages will be stored within Belden Horizon Data Operations when cloud providers are online. &#x20;

## Step 5: Enable the Connector

**To enable the connector:&#x20;**

1. Return to the *Belden Horizon Data Operations Integration* browser tab.
2. Click the connection toggle on the connector tile.&#x20;
   The connector shows connected after verifying the connection.

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/fCnpKlRxyMp2KkMxhA3MZ_googlecloud.png" size="60" width="344" height="253" caption="Toggle to enable connector" position="center" showCaption="true"}

## Step 6: Create Inbound Topics for Google Cloud Connector

You will now need to create topics from the tags you added in Step 3. &#x20;

Before creating the topics copy the *Raw Topic* parameter for all tags you want to use for topics. See [Manage Tags](https://public-docs.litmus.io/bhdo/manage-tags) for more information

**To create inbound topics:&#x20;**

1. Navigate to **Integration**.&#x20;
2. Click the connector tile.&#x20;
3. Click the **Topics&#x20;**&#x74;ab.&#x20;
4. Click th&#x65;**&#x20;Add a new subscription** icon.&#x20;
   Th&#x65;*&#x20;Data Integration&#x20;*&#x64;ialog box appears.&#x20;

   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/JH5GLQaFAToeB5wOzP0Nt_addanewsubscription.png" size="80" width="1148" height="570" caption="Add a new subscription icon" position="center" showCaption="true"}
5. Configure the following parameters.&#x20;
   - **Data Direction**: Select **Local to Remote - Inbound**.&#x20;
   - **Local Data Topic**: Paste th&#x65;*&#x20;Raw Topic* for the tag created in Step 2. &#x20;
   - **Remote Data Topic**: Copy and paste the *Publication&#x20;*&#x74;opic from your Google Cloud Platform.&#x20;
   - **Enable**: Select the toggle to enable the topic.&#x20;
6. Click **Yes&#x20;**&#x74;o add the topic.&#x20;
7. From the connector tile, click the toggle to disable and then enable the connector to restart it.&#x20;

   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/yeiVRj2vimEkfcl09kLL9_googlecloud.png" size="60" width="344" height="253" caption="Toggle to enable connector" position="center" showCaption="true"}

See the *Connector Topics* section in [Manage Connectors](https://public-docs.litmus.io/bhdo/manage-connectors) for more details.&#x20;

## Step 7: Enable Topics

To ensure all topics are enabled, return to the **Topics&#x20;**&#x74;ab and click the **Enable all topics** icon.&#x20;

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/C-bDrSwEXUH1TT3X_QJCp_enable-all-topics.png" size="80" width="1148" height="570" caption="Enable all topics icon" position="center" showCaption="true"}

## Step 8: Send Messages in Google Cloud Platform

Start sending messages through the *publication&#x20;*&#x74;opic (created in Step 1) from the Google Cloud Platform.

## Step 9: Verify Connection in Belden Horizon Data Operations

You can do one of the following to verify the connection in Belden Horizon Data Operations:

- [Create a Flow](https://public-docs.litmus.io/bhdo/create-a-flow) to view the messages coming from Google Pub/Sub through the connector you created.&#x20;
- Visualize the incoming data using one of the dedicated [Applications](https://public-docs.litmus.io/bhdo/applications) such as Grafana.&#x20;

