使用发布/订阅消息触发Cloud Composer DAG [英] Trigger Cloud Composer DAG with a Pub/Sub message

查看:147
本文介绍了使用发布/订阅消息触发Cloud Composer DAG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建要通过发布/订阅消息触发的Cloud Composer DAG。
以下是Google的以下示例,每次在Cloud Storage存储桶中发生更改时都会触发DAG:
https://cloud.google.com/composer/docs/how-to/using/triggering-with-gcf

I am trying to create a Cloud Composer DAG to be triggered via a Pub/Sub message. There is the following example from Google which triggers a DAG every time a change occurs in a Cloud Storage bucket: https://cloud.google.com/composer/docs/how-to/using/triggering-with-gcf

但是,开始时他们说,您可以触发DAG来响应事件,例如Cloud Storage存储桶中的更改或推送到Cloud Pub的消息/ Sub 。我花了很多时间试图弄清楚该怎么做,但没有结果。

However, on the beginning they say you can trigger DAGs in response to events, such as a change in a Cloud Storage bucket or a message pushed to Cloud Pub/Sub. I have spent a lot of time try to figure out how that can be done, but no result.

您能帮忙还是给我一些指导?谢谢!

Can you please help or giving me some directions? Thanks!

推荐答案

有两种方法可以通过发布/订阅事件触发DAG。

There are 2 ways to trigger a DAG by a Pub/Sub events.


  1. 您可以放置​​ PubSubPullSensor 在DAG的开头。每当PubSubPullSensor可以拉出发布/订阅消息时,就会触发您的DAG。它将执行您DAG中的其余任务。

  2. 您还可以创建充当发布/订阅触发器的云功能。并将 Composer DAG触发逻辑放入其中云功能触发器。当消息发布到发布/订阅主题时,云功能应该能够触发Composer DAG。

  1. You can place a PubSubPullSensor at the beginning of your DAG. Your DAG will be triggered every time a Pub/Sub message can be pulled by the PubSubPullSensor. And it will execute the rest of the tasks in your DAG.
  2. You can also create a Cloud Function that acts as Pub/Sub trigger. And put the Composer DAG triggering logic inside the Cloud Function trigger. When a message is published to the Pub/Sub topic, the Cloud Function should be able to trigger the Composer DAG.

这篇关于使用发布/订阅消息触发Cloud Composer DAG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆