Skip to main content
Skip table of contents

Google Pub/Sub

ClearBlade provides a native integration for high-performance interactions with Google Pub/Sub. This is ideal for sending MQTT messages into Google Cloud services or integrating data from other Google Cloud services directly with your ClearBlade application.


ClearBlade uses the Pub/Sub Golang library, which leverages a persistent TCP connection under the covers.

The topics entered during Pub/Sub connection creation will be added as subscribers to the topic tree. The Pub/Sub connection will implement the client interface in core_messaging/broker/client_manager.go. Use the Publish function to forward messages.



GET, POST, PUT, and DELETE support


Body required. The body can have IoT Core and non-IoT Core topics. type and target are required for IoT Core topics. type can be 1 for events and 2 for state:

    "credentials_map": { // This is the service account JSON object
        "type": "service_account",
        "project_id": "myprojectid",
        "private_key_id": "blahblahblah",
        "private_key": "<priv_key>",
        "client_email": "",
        "client_id": "9126871624161341",
        "auth_uri": "",
        "token_uri": "",
        "auth_provider_x509_cert_url": "",
        "client_x509_cert_url": ""
    "project_id": "myprojectid",
    "topics": [ // This is to send data to Google Pub/Sub
        {"path": "iotdemo"}, // Non IoT Core topic
        {"path": "/devices/+/events", "type": 1, "target": "performance-testing"}, // IoT Core topic
        {"path": "/devices/+/events/sub", "type": 1, "target": "performance-testing-sub", "sub_folder": "sub"}, // IoT Core topic
        {"path": "/devices/+/state", "type": 2, "target": "performance-testing-state"} // IoT Core topic
    "forwarders": { // This is to receive Google Pub/Sub messages
      "ack_strategy": 0,
      "poll_rate": 5000,
      "max_messages_per_poll": 2,
      "subscriptions": [
              "mqtt_topic": "pubsub",
              "pubsub_subscription": "test-sub"

path is the topic the Pub/Sub client will subscribe to internally to the ClearBlade broker. type is the topic type. No type represents a non-IoT Core topic. 1 is for event and 2 is for state. target is the topic the Pub/Sub client will publish to in Pub/Sub. sub_folder is for the event's topic if it has a subfolder.


No query support. Admin or Dev.

Returns the same object as the POST body.


GET and DELETE support only. GET obtains all Pub/Sub connections for that system, and DELETE deletes all.

Receiving data

The following parameters exist for setting up your Google Pub/Sub forwarders to ClearBlade MQTT:

ack_strategy: 0 = ack immediately, 1 = never ack. For now, 0 should always be used.

poll_rate: Time (ms) between sending message batches to the broker. 0 will send messages immediately.

max_messages_per_poll: Max number of messages to send in a single batch to the broker. Implicit minimum value of 1.

Messages are received by ClearBlade as soon as possible from Google. ClearBlade will buffer them internally and send them in batches as defined above.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.