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.
Configuration
Section titled “Configuration”- 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.
Outgoing message format
Section titled “Outgoing message format”On Success, adds to metadata: messageId (Pub/Sub message ID).
On Failure, adds to metadata: error.
Message processing algorithm
Section titled “Message processing algorithm”- Resolve topic name and attribute templates from message data and metadata.
- Publish the message data as the Pub/Sub message body.
- On success: add
messageIdto metadata; route viaSuccess. - On error: add
errorto metadata; route viaFailure.
Output connections
Section titled “Output connections”| Connection | Condition |
|---|---|
Success | Message published. Metadata includes messageId. |
Failure | Timeout, Pub/Sub error, invalid credentials, or unexpected error. |
Examples
Section titled “Examples”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.
JSON schema
Section titled “JSON schema”{ "$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" } }}