使用Dataflow Java SDK 2从Pubsub读取 [英] Reading from Pubsub using Dataflow Java SDK 2

查看:124
本文介绍了使用Dataflow Java SDK 2从Pubsub读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关Java SDK 2.x的Google Cloud Platform的许多文档都告诉您参考Beam文档.

使用Dataflow从PubSub读取数据时,我仍应继续执行PubsubIO.Read.named("name").topic("));

还是我应该做其他事情?

还以此为基础,是否有一种方法可以仅将数据流接收到的PubSub数据打印到标准输出或文件中?

解决方案

对于Apache Beam 2.2.0,您可以定义以下转换以从发布/订阅订阅中提取消息:

 PubsubIO.readMessages().fromSubscription("subscription_name")
 

这是定义将从Pub/Sub中提取消息的转换的一种方法.但是,PubsubIO类包含用于提取消息的不同方法.每种方法的功能略有不同.参见 TextIO 文档.请参阅记录管道消息文档,以将发布/订阅消息写入stdout./p>

A lot of the documentation for the Google Cloud Platform for Java SDK 2.x tell you to reference Beam documentation.

When reading from PubSub using Dataflow, should I still be doing PubsubIO.Read.named("name").topic("");

Or should I be doing something else?

Also building off of that, is there a way to just print PubSub data received by the Dataflow to standard output or to a file?

解决方案

For Apache Beam 2.2.0, you can define the following transform to pull messages from a Pub/Sub subscription:

PubsubIO.readMessages().fromSubscription("subscription_name")

This is one way to define a transform that will pull messages from Pub/Sub. However, the PubsubIO class contains different methods for pulling messages. Each method has slightly different functionality. See the PubsubIO documentation.

You can write the Pub/Sub messages to a file using the TextIO class. See the examples in the TextIO documentation. See the Logging Pipeline Messages documentation for writing Pub/Sub messages to stdout.

这篇关于使用Dataflow Java SDK 2从Pubsub读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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