Cloud Pub/Sub trigger

The Cloud Pub/Sub trigger lets you run your integration based on the events in your Pub/Sub middleware.

Using this trigger, you can execute an integration whenever a publisher writes a message to your chosen topic. When this trigger executes, it also writes the published message to the CloudPubSubMessage output variable. Based on your requirements, you can use this variable in your downstream triggers or tasks.

Before you begin

Ensure that you perform the following tasks in your Google Cloud project before configuring the Cloud Pub/Sub trigger.

  • Assign the following IAM roles to your default service account (service-PROJECT_NUMBER@gcp-sa-apigee.iam.gserviceaccount.com):
  • Confirm that you have a Pub/Sub topic. To create a new Pub/Sub topic:
    1. Go to the Pub/Sub topics page in the Cloud console.

      Go to the Pub/Sub topics page

    2. Click Create a topic.
    3. In the Topic ID field, provide a unique topic name.
    4. Click Save.

For more information about managing access using IAM roles, see Access control.

For information on granting roles to principals, see Granting, changing, and revoking access.

Add a Cloud Pub/Sub trigger

To add a Cloud Pub/Sub trigger to a new or existing integration, follow the steps below:
  1. In the Apigee UI, select your Apigee Organization.
  2. Click Develop > Integrations.
  3. Select an existing integration or create a new integration by clicking Create Integration.

    If you are creating a new integration:

    1. Enter a name and description in the Create Integration dialog.
    2. Select a Region for the integration from the list of supported regions.
    3. Click Create.

    This opens the integration in the integration designer.

  4. In the integration designer navigation bar, click +Add a task/trigger > Triggers to view the list of available triggers.
  5. Click and place the Cloud Pub/Sub trigger element to the designer.

Configure a Cloud Pub/Sub trigger

Click the Cloud Pub/Sub trigger element in the integration editor to view the trigger configuration pane, and then do the following tasks:

Specify the topic the trigger should listen to in the Pub/Sub topic field in the following format:

projects/PROJECT_ID/topics/TOPIC_ID

To view all the available topics in your Google Cloud project, see the Topic name column in Topics.

Replace the following:

  • PROJECT_ID: the Google Cloud project where your topic is created.
  • TOPIC_ID: the ID of your Pub/Sub topic.

Trigger Output

For each event, the Cloud Pub/Sub trigger generates a CloudPubSubMessage output variable which you can use in your downstream tasks. The variable is in JSON format and has the PubsubMessage structure.

Considerations

  • The maximum size of a Pub/Sub message is 10 MB. To understand all the limitations of Pub/Sub, see Pub/Sub quotas and limits.
  • It is possible that Pub/Sub writes the same message more than once to a topic. To understand this behavior of Pub/Sub, see At-Least-Once delivery. Therefore, you must design your integration to be idempotent so that it doesn't allow a message to be written more than once to a topic.
  • If you unpublish an integration, the Pub/Sub subscription is not deleted to prevent loss of messages. However, if you delete the published version or all the integration versions of an integration, then the Pub/Sub subscription is also deleted.