使用Dataflow Java SDK 2从Pubsub读取 [英] Reading from Pubsub using Dataflow Java SDK 2
问题描述
有关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屋!