return toBuilder().setTimestampAttribute(timestampAttribute).build();
/** Returns A {@link PTransform} that continuously reads from a Google Cloud Pub/Sub stream. */ private static <T> Read<T> read() { return new AutoValue_PubsubIO_Read.Builder<T>().setNeedsAttributes(false).build(); }
/** * Causes the source to return a PubsubMessage that includes Pubsub attributes, and uses the * given parsing function to transform the PubsubMessage into an output type. A Coder for the * output type T must be registered or set on the output via {@link * PCollection#setCoder(Coder)}. */ private Read<T> withCoderAndParseFn(Coder<T> coder, SimpleFunction<PubsubMessage, T> parseFn) { return toBuilder().setCoder(coder).setParseFn(parseFn).build(); }
/** Like {@code subscription()} but with a {@link ValueProvider}. */ public Read<T> fromSubscription(ValueProvider<String> subscription) { if (subscription.isAccessible()) { // Validate. PubsubSubscription.fromPath(subscription.get()); } return toBuilder() .setSubscriptionProvider( NestedValueProvider.of(subscription, new SubscriptionTranslator())) .build(); }
/** * Returns A {@link PTransform} that continuously reads from a Google Cloud Pub/Sub stream. The * messages will contain both a {@link PubsubMessage#getPayload() payload} and {@link * PubsubMessage#getAttributeMap() attributes}. */ public static Read<PubsubMessage> readMessagesWithAttributes() { return new AutoValue_PubsubIO_Read.Builder<PubsubMessage>() .setCoder(PubsubMessageWithAttributesCoder.of()) .setParseFn(new IdentityMessageFn()) .setNeedsAttributes(true) .build(); }
/** * When reading from Cloud Pub/Sub where unique record identifiers are provided as Pub/Sub * message attributes, specifies the name of the attribute containing the unique identifier. The * value of the attribute can be any string that uniquely identifies this record. * * <p>Pub/Sub cannot guarantee that no duplicate data will be delivered on the Pub/Sub stream. * If {@code idAttribute} is not provided, Beam cannot guarantee that no duplicate data will be * delivered, and deduplication of the stream will be strictly best effort. */ public Read<T> withIdAttribute(String idAttribute) { return toBuilder().setIdAttribute(idAttribute).build(); }
/** * Returns A {@link PTransform} that continuously reads from a Google Cloud Pub/Sub stream. The * messages will only contain a {@link PubsubMessage#getPayload() payload}, but no {@link * PubsubMessage#getAttributeMap() attributes}. */ public static Read<PubsubMessage> readMessages() { return new AutoValue_PubsubIO_Read.Builder<PubsubMessage>() .setCoder(PubsubMessagePayloadOnlyCoder.of()) .setParseFn(new IdentityMessageFn()) .setNeedsAttributes(false) .build(); }
/** Like {@code topic()} but with a {@link ValueProvider}. */ public Read<T> fromTopic(ValueProvider<String> topic) { if (topic.isAccessible()) { // Validate. PubsubTopic.fromPath(topic.get()); } return toBuilder() .setTopicProvider(NestedValueProvider.of(topic, new TopicTranslator())) .build(); }