Dataflow 应该使用来自 Pub/Sub 主题或订阅的事件吗?
Should Dataflow consume events from a Pub/Sub topic or subscription?
我希望使用数据流将事件从 PubSub 流式传输到 BigQuery。我看到在 GCP 中有两个模板可以执行此操作:一个是 Dataflow 从主题中读取消息;另一个是 Dataflow 从主题中读取消息的模板。和一个来自订阅。
在这里使用订阅而不是仅仅使用主题中的事件有什么好处?
Core concepts
Topic: A named resource to which messages are sent by publishers.
Subscription: A named resource representing the stream of messages from a single, specific topic, to be delivered to the subscribing
application.
根据核心概念,区别很简单:
当您想要从 Dataflow 发布 消息到 Pub/Sub 时使用 Topic(实际上,对于给定的主题)。
当您想在数据流中使用来自Pub/Sub的消息时,使用订阅。
因此,对于您的情况,请订阅。
更多信息:
请注意 Pub/Sub 使用自己的消息存储管理主题。但是,当您希望在 BigQuery 中也移动这些消息(并最终执行您自己的分析)时,Cloud Pub/Sub Topic to BigQuery 模板特别有用。
The Cloud Pub/Sub Topic to BigQuery template is a streaming pipeline
that reads JSON-formatted messages from a Cloud Pub/Sub topic and
writes them to a BigQuery table. You can use the template as a quick
solution to move Cloud Pub/Sub data to BigQuery. The template reads
JSON-formatted messages from Cloud Pub/Sub and converts them to
BigQuery elements.
https://cloud.google.com/dataflow/docs/guides/templates/provided-streaming#cloudpubsubtobigquery
免责声明:评论和意见是我自己的,不代表我雇主的观点。
BigQuery 主题和 BigQuery 模板订阅都使用来自 Pub/Sub 的消息并将它们流式传输到 BigQuery。
如果您使用 Topic to BigQuery 模板,Dataflow 会在后台为您创建一个订阅,从指定的主题中读取数据。如果您使用订阅 BigQuery 模板,则需要提供您自己的订阅。
您可以使用订阅 BigQuery 模板,通过创建多个 subscription-connected 从同一主题读取的 BigQuery 管道来模拟主题到 BigQuery 模板的行为。
对于新部署,最好使用订阅 BigQuery 模板。如果您使用主题到 BigQuery 模板停止并重新启动管道,将创建一个新订阅,这可能会导致您错过管道关闭时发布的一些消息。订阅 BigQuery 模板没有这个缺点,因为即使在管道重新启动后它也使用相同的订阅。
我希望使用数据流将事件从 PubSub 流式传输到 BigQuery。我看到在 GCP 中有两个模板可以执行此操作:一个是 Dataflow 从主题中读取消息;另一个是 Dataflow 从主题中读取消息的模板。和一个来自订阅。
在这里使用订阅而不是仅仅使用主题中的事件有什么好处?
Core concepts
Topic: A named resource to which messages are sent by publishers.
Subscription: A named resource representing the stream of messages from a single, specific topic, to be delivered to the subscribing application.
根据核心概念,区别很简单:
当您想要从 Dataflow 发布 消息到 Pub/Sub 时使用 Topic(实际上,对于给定的主题)。
当您想在数据流中使用来自Pub/Sub的消息时,使用订阅。
因此,对于您的情况,请订阅。
更多信息:
请注意 Pub/Sub 使用自己的消息存储管理主题。但是,当您希望在 BigQuery 中也移动这些消息(并最终执行您自己的分析)时,Cloud Pub/Sub Topic to BigQuery 模板特别有用。
The Cloud Pub/Sub Topic to BigQuery template is a streaming pipeline that reads JSON-formatted messages from a Cloud Pub/Sub topic and writes them to a BigQuery table. You can use the template as a quick solution to move Cloud Pub/Sub data to BigQuery. The template reads JSON-formatted messages from Cloud Pub/Sub and converts them to BigQuery elements.
https://cloud.google.com/dataflow/docs/guides/templates/provided-streaming#cloudpubsubtobigquery
免责声明:评论和意见是我自己的,不代表我雇主的观点。
BigQuery 主题和 BigQuery 模板订阅都使用来自 Pub/Sub 的消息并将它们流式传输到 BigQuery。
如果您使用 Topic to BigQuery 模板,Dataflow 会在后台为您创建一个订阅,从指定的主题中读取数据。如果您使用订阅 BigQuery 模板,则需要提供您自己的订阅。
您可以使用订阅 BigQuery 模板,通过创建多个 subscription-connected 从同一主题读取的 BigQuery 管道来模拟主题到 BigQuery 模板的行为。
对于新部署,最好使用订阅 BigQuery 模板。如果您使用主题到 BigQuery 模板停止并重新启动管道,将创建一个新订阅,这可能会导致您错过管道关闭时发布的一些消息。订阅 BigQuery 模板没有这个缺点,因为即使在管道重新启动后它也使用相同的订阅。