Skip to content

Cookie preferences

We use cookies for our own analytics, to see how our campaigns perform and, if you allow it, to load content from other services such as the Google site search. We never sell your data. Necessary cookies keep the site working and cannot be switched off. See our Cookie Policy for details and our Privacy Policy for how we handle personal data.

Security, load balancing and remembering your cookie choice.

Show us which pages people read, how they find the site and where they get stuck, so we can improve it (Google Analytics, Microsoft Clarity).

Show us which of our ad campaigns bring visitors to the site and remember the campaign or partner link you arrived from (Google Ads, LinkedIn, Meta, partner program). We do not use these cookies to build advertising profiles.

Load the site search from Google when you use it. Google sets its own cookies and shows ads in the search results.

© 2026 The ThingsBoard Authors
22.5k Try for free

ThingsBoard Cloud

Choose your data region

Your data stays in the region you choose, for residency and compliance. No credit card required.

Rather run it yourself? Install on your own servers

GCP Pub/Sub

Use this node to publish messages to a Google Cloud Pub/Sub topic — for example, streaming device telemetry to a Dataflow pipeline, triggering Cloud Functions on alarm events, or integrating ThingsBoard data with BigQuery via a Pub/Sub subscription.

  • Project ID — required. GCP project identifier.
  • Topic name — required. Pub/Sub topic name (not the full path; the node constructs projects/{projectId}/topics/{topicName}). Supports templatization.
  • Message attributes — optional. Custom Pub/Sub message attributes as key-value pairs. Both keys and values support templatization.
  • Service account key — required. GCP service account key JSON with Pub/Sub Publisher role.

Fixed retry settings: 10 s total timeout, 50 ms initial delay, 2 s max delay, 1.1× multiplier, 2–10 s RPC timeout.

On Success, adds to metadata: messageId (Pub/Sub message ID).

On Failure, adds to metadata: error.

  1. Resolve topic name and attribute templates from message data and metadata.
  2. Publish the message data as the Pub/Sub message body.
  3. On success: add messageId to metadata; route via Success.
  4. On error: add error to metadata; route via Failure.
Connection Condition
Success Message published. Metadata includes messageId.
Failure Timeout, Pub/Sub error, invalid credentials, or unexpected error.

Example 1 — Publish telemetry to Pub/Sub

Section titled “Example 1 — Publish telemetry to Pub/Sub”

Data: { "temperature": 25.5 }.

{
"projectId": "my-gcp-project",
"topicName": "device-telemetry",
"messageAttributes": {},
"serviceAccountKey": "{ \"type\": \"service_account\", ... }"
}

Outgoing metadata adds: { "messageId": "123456789" }. Routes via Success.

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "TbPubSubNodeConfiguration",
"type": "object",
"required": ["projectId", "topicName", "serviceAccountKey"],
"additionalProperties": false,
"properties": {
"projectId": { "type": "string" },
"topicName": { "type": "string" },
"messageAttributes": { "type": "object", "additionalProperties": { "type": "string" } },
"serviceAccountKey": { "type": "string" }
}
}