将消息发布到Dataflow中的Pubsub主题

时间:2021-11-04 15:29:31

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.

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

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

1 个解决方案

#1


2  

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

从Dataflow作业向PubSub主题发布消息的最佳方法是使用PubsubIO类。例:

Pipeline p = Pipeline.create();

// do some transforms

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

Reference: PubsubIO

参考:PubsubIO

#1


2  

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

从Dataflow作业向PubSub主题发布消息的最佳方法是使用PubsubIO类。例:

Pipeline p = Pipeline.create();

// do some transforms

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

Reference: PubsubIO

参考:PubsubIO