Configuring the Cloud Pub/Sub Trigger

You're viewing Apigee X documentation.
View Apigee Edge documentation.

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

Using this trigger, you can start 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 assign the following IAM roles to the Apigee Service Agent ( service-PROJECT_NUMBER@gcp-sa-apigee.iam.gserviceaccount.com ) in your Google Cloud project before using the Cloud Pub/Sub Trigger.

Add a Cloud Pub/Sub Trigger

To add a Cloud Pub/Sub Trigger to a new or existing integration, follow the steps below:
  1. Go to the Apigee UI and sign in.
  2. Select your organization using the drop-down menu in the upper left corner of the UI.
  3. Click Develop > Integrations to view the list of available integrations.

  4. Select an existing integration or click Create new
  5. In the integration designer, click + Add a task/trigger to view the task and trigger selection dialog.
  6. Click Triggers to view the available triggers.
  7. Drag 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 designer to view the trigger configuration pane.

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

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

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

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.