com.google.cloud.dataflow.sdk.io

## Class PubsubIO.Write

- java.lang.Object
- - com.google.cloud.dataflow.sdk.io.PubsubIO.Write

Enclosing class:
  PubsubIO

    public static class PubsubIO.Write
    extends Object

A `PTransform` that continuously writes a `PCollection` of `Strings` to a Cloud Pub/Sub stream.

### Nested Class Summary

Nested Classes
`static class` `PubsubIO.Write.Bound<T>` A `PTransform` that writes an unbounded `PCollection` of `Strings` to a Cloud Pub/Sub stream.

### Method Summary

All Methods Static Methods Concrete Methods
`static PubsubIO.Write.Bound<String>` `idLabel(String idLabel)` Creates a transform that writes to Pub/Sub, adding each record's unique identifier to the published messages in an attribute with the specified name.
`static PubsubIO.Write.Bound<String>` `named(String name)` Creates a transform that writes to Pub/Sub with the given step name.
`static PubsubIO.Write.Bound<String>` `timestampLabel(String timestampLabel)` Creates a transform that writes to Pub/Sub, adds each record's timestamp to the published messages in an attribute with the specified name.
`static PubsubIO.Write.Bound<String>` `topic(String topic)` Creates a transform that publishes to the specified topic.
`static <T> PubsubIO.Write.Bound<T>` `withCoder(Coder<T> coder)` Creates a transform that uses the given `Coder` to encode each of the elements of the input collection into an output message.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### named

    public static PubsubIO.Write.Bound<String> named(String name)

Creates a transform that writes to Pub/Sub with the given step name.

#### topic

    public static PubsubIO.Write.Bound<String> topic(String topic)

Creates a transform that publishes to the specified topic.

See `PubsubIO.PubsubTopic.fromPath(String)` for more details on the format of the `topic` string.

#### timestampLabel

    public static PubsubIO.Write.Bound<String> timestampLabel(String timestampLabel)

Creates a transform that writes to Pub/Sub, adds each record's timestamp to the published messages in an attribute with the specified name. The value of the attribute will be a number representing the number of milliseconds since the Unix epoch. For example, if using the Joda time classes, `Instant.Instant(long)` can be used to parse this value.

If the output from this sink is being read by another Dataflow source, then `PubsubIO.Read.timestampLabel(String)` can be used to ensure the other source reads these timestamps from the appropriate attribute.

#### idLabel

    public static PubsubIO.Write.Bound<String> idLabel(String idLabel)

Creates a transform that writes to Pub/Sub, adding each record's unique identifier to the published messages in an attribute with the specified name. The value of the attribute is an opaque string.

If the the output from this sink is being read by another Dataflow source, then `PubsubIO.Read.idLabel(String)` can be used to ensure that* the other source reads these unique identifiers from the appropriate attribute.

#### withCoder

    public static <T> PubsubIO.Write.Bound<T> withCoder(Coder<T> coder)

Creates a transform that uses the given `Coder` to encode each of the elements of the input collection into an output message.

By default, uses `StringUtf8Coder`, which writes input Java strings directly as records.

Type Parameters:
  `T` - the type of the elements of the input PCollection