use of org.apache.beam.sdk.io.gcp.pubsublite.internal.PubsubLiteSink in project beam by apache.
the class PubsubLiteIO method write.
/**
* Write messages to Pub/Sub Lite.
*
* <pre>{@code
* TopicPath topicPath =
* TopicPath.newBuilder()
* .setProjectNumber(projectNum)
* .setLocation(zone)
* .setName(topicName)
* .build();
*
* PCollection<Message> messages = ...;
* messages.apply(PubsubLiteIO.write(
* PublisherOptions.newBuilder().setTopicPath(topicPath).build());
*
* }</pre>
*/
public static PTransform<PCollection<PubSubMessage>, PDone> write(PublisherOptions options) {
return new PTransform<PCollection<PubSubMessage>, PDone>() {
@Override
public PDone expand(PCollection<PubSubMessage> input) {
PubsubLiteSink sink = new PubsubLiteSink(options);
input.apply("Write", ParDo.of(sink));
return PDone.in(input.getPipeline());
}
};
}
Aggregations