Skip to main content

Google Pub/Sub event trigger

The Google Pub/Sub event type (Events family) consumes a Pub/Sub subscription and starts a workflow for each delivered message.

Before you begin​

  • A Google Cloud project with the Pub/Sub API enabled.
  • A topic Pub/Sub created.
  • A pull mode subscription associated with this topic, so Ecosystem can consume the messages.
  • A service account key (service account with the Pub/Sub Subscriber role on the subscription), entered in the trigger's Advanced options.
Keys and credentials

Do not paste a JSON key or credentials in clear text in the free fields: use dictionary variables.

Parameters​

ParameterTypeRequiredDefaultDescription
NameString✅—Trigger label in the lists.
DescriptionString✅—Summary of the trigger's purpose, for reviews and maintenance.
Path (slug)String✅—Identifier of the public URL, generated from the name.
TagsList❌—Labels to filter and find the trigger in the lists.
AppString❌—Business application to attach to the trigger for mapping — see Apps.
Project ID (projectId)String✅—GCP project containing the subscription to consume.
Subscription ID (subscription)String✅—Pull subscription consumed by the trigger.

Advanced options​

ParameterTypeRequiredDefaultDescription
Service account keyJSON (masked)❌—GCP service account key with the Pub/Sub Subscriber role on the subscription. Reference it via a dictionary variable rather than pasting the value in clear text.

The service account must at minimum be able to consume the subscription (role of the Subscriber type on the resource concerned).

Input​

The trigger receives each message published on the associated subscription.

{
"data": { "orderId": "CMD-4821", "total": 149.9 }
}

Output​

The workflow receives the published message in data:

PropertyDescription
dataContent of the published message.
AttributesBusiness attributes carried by the event are exposed in the trigger data.

The exact format depends on the message published by the sender.

Errors​

  • Acknowledgment timeout (ack deadline) — Pub/Sub imposes a deadline to acknowledge a message; beyond it, the message can be redelivered. Configure a timeout adapted to the duration of your workflow.
  • Repeated failures — the message can be refused (nack) and become available again for a new attempt according to the subscription policy, or moved to a dead-letter topic.
  • Idempotence — a message can be delivered more than once: design the processing as idempotent.

Limits​

  • Pull mode required — the subscription must be in pull mode so Ecosystem can consume the messages.
  • Ack deadline — the workflow duration is limited by the ack deadline imposed by Pub/Sub.

Example​

  1. In the Google Cloud console: create a topic (e.g. orders-events) and a linked pull subscription (e.g. orders-events-sub). Note the project ID and the subscription name.
  2. In Ecosystem: prepare the service account key (Pub/Sub Subscriber role on the subscription), ideally referenced in a dictionary.
  3. Create the trigger: Google Pub/Sub event type, fill in the name, project ID and subscription ID, then add the service account key in the Advanced options.
  4. Associate a workflow that receives the message, processes the payload, then is acknowledged or returned depending on the result.
  5. Deploy in the target environment: message consumption starts according to the configuration.

See also​