Radhika
Radhika

Reputation: 23

Publish messages to Pubsub topic in 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();

Upvotes: 0

Views: 4718

Answers (1)

Andrew Nguonly
Andrew Nguonly

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

Related Questions