将消息发布到数据流中的Pubsub主题 [英] Publish messages to Pubsub topic in Dataflow

查看:79
本文介绍了将消息发布到数据流中的Pubsub主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Dataflow中将消息发布到发布/订阅主题的推荐方法是什么.我曾经使用过客户端API,但认为这不是在Dataflow中处理此问题的最佳方法.

What is the recommended way to publish messages to a Pub/Sub topic in Dataflow. I have worked with client APIs but do not think it is the best way to handle this in Dataflow.

PublishResponse response = client.projects().topics()
                        .publish(fullTopicName, publishRequest)
                        .execute();

推荐答案

将消息从Dataflow作业发布到PubSub主题的最佳方法是使用 PubsubIO 类.示例:

The best way to publish messages to a PubSub topic from a Dataflow job is to use the PubsubIO class. Example:

Pipeline p = Pipeline.create();

// do some transforms

p.apply("publish message", PubsubIO.write().to("pubsub/topic"));

参考: PubsubIO

这篇关于将消息发布到数据流中的Pubsub主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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