Skip to content
Stand with Ukraine flag

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.
ConnectionCondition
SuccessMessage published. Metadata includes messageId.
FailureTimeout, 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" }
}
}