The PubSubPullSensor
is part of a DAG. The dag needs to be running in order to the sensor to be executed, that's why it didn't work.
I think that the most striaghtforward approach would be to use cloud functions, but if that's not possible, the second option would be to use another server (it could be another computing option within GCP: Cloud AppEngine, Cloud Run, etc.) to receive the Pub/Sub message and trigger the dag. Basically, the same idea as Pub/Sub + Cloud Functions, without functions.
If you don't want to follow this approach, and want to trigger the Dag within the same Composer environment, you could use PubSubPullSensor
on a running dag and use the TriggerDagRunOperator
when needed.
This idea can be used in many forms; however, the tricky thing is that PubSubPullSensor
needs to be executed in a running dag. A possible solution for this, is to schedule the dag to run often, for example every 5 minutes