tests.system.google.event_scheduling.example_event_schedule_pubsub

Example Airflow DAG that demonstrates using Google Cloud Pub/Sub with MessageQueueTrigger and Asset Watchers for event-driven workflows.

This example shows how to create a DAG that triggers when messages arrive in a Google Cloud Pub/Sub subscription using Asset Watchers.

Prerequisites

Before running this example, ensure you have:

  1. A GCP project with Pub/Sub API enabled

  2. The following Pub/Sub resources created in your project:

    • Topic: test-topic

    • Subscription: test-subscription

You can create these resources using:

# Create topic
gcloud pubsub topics create test-topic --project={PROJECT_ID}

# Create subscription
gcloud pubsub subscriptions create test-subscription \
    --topic=test-topic --project={PROJECT_ID}

How to test

  1. Ensure the Pub/Sub resources exist (see Prerequisites above)

  2. Publish a message to trigger the DAG:

    gcloud pubsub topics publish test-topic \
        --message="Test message" --project={PROJECT_ID}
    
  3. The DAG will be triggered automatically when the message arrives

Attributes

trigger

asset

process_message_task

test_run

Module Contents

tests.system.google.event_scheduling.example_event_schedule_pubsub.trigger[source]
tests.system.google.event_scheduling.example_event_schedule_pubsub.asset[source]
tests.system.google.event_scheduling.example_event_schedule_pubsub.process_message_task[source]
tests.system.google.event_scheduling.example_event_schedule_pubsub.test_run[source]

Was this entry helpful?