Reputation: 23
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();
Upvotes: 0
Views: 4718
Reputation: 2621
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"));
Reference: PubsubIO
Upvotes: 3