public static class KafkaIO.Read<K,V> extends KafkaIO.TypedRead<K,V>
PTransform to read from Kafka topics. See KafkaIO for more
information on usage and configuration.consumerConfig, consumerFactoryFn, keyCoder, maxNumRecords, maxReadTime, timestampFn, topicPartitions, topics, valueCoder, watermarkFnname| Modifier and Type | Method and Description |
|---|---|
KafkaIO.Read<K,V> |
updateConsumerProperties(Map<String,Object> configUpdates)
Update consumer configuration with new properties.
|
KafkaIO.Read<K,V> |
withBootstrapServers(String bootstrapServers)
Returns a new
KafkaIO.Read with Kafka consumer pointing to bootstrapServers. |
KafkaIO.Read<K,V> |
withConsumerFactoryFn(SerializableFunction<Map<String,Object>,org.apache.kafka.clients.consumer.Consumer<byte[],byte[]>> consumerFactoryFn)
A factory to create Kafka
Consumer from consumer configuration. |
<KeyT> KafkaIO.Read<KeyT,V> |
withKeyCoder(Coder<KeyT> keyCoder)
Returns a new
KafkaIO.Read with Coder for key bytes. |
KafkaIO.Read<K,V> |
withMaxNumRecords(long maxNumRecords)
Similar to
Read.Unbounded.withMaxNumRecords(long). |
KafkaIO.Read<K,V> |
withMaxReadTime(org.joda.time.Duration maxReadTime)
Similar to
Read.Unbounded.withMaxReadTime(Duration). |
KafkaIO.Read<K,V> |
withTopicPartitions(List<org.apache.kafka.common.TopicPartition> topicPartitions)
Returns a new
KafkaIO.Read that reads from the partitions. |
KafkaIO.Read<K,V> |
withTopics(List<String> topics)
Returns a new
KafkaIO.Read that reads from the topics. |
<ValueT> KafkaIO.Read<K,ValueT> |
withValueCoder(Coder<ValueT> valueCoder)
Returns a new
KafkaIO.Read with Coder for value bytes. |
apply, withoutMetadata, withTimestampFn, withTimestampFn2, withWatermarkFn, withWatermarkFn2getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, populateDisplayData, toString, validatepublic KafkaIO.Read<K,V> withBootstrapServers(String bootstrapServers)
KafkaIO.Read with Kafka consumer pointing to bootstrapServers.public KafkaIO.Read<K,V> withTopics(List<String> topics)
KafkaIO.Read that reads from the topics. All the partitions are from each
of the topics is read.
See UnboundedKafkaSource#generateInitialSplits(int, PipelineOptions) for description
of how the partitions are distributed among the splits.public KafkaIO.Read<K,V> withTopicPartitions(List<org.apache.kafka.common.TopicPartition> topicPartitions)
KafkaIO.Read that reads from the partitions. This allows reading only a subset
of partitions for one or more topics when (if ever) needed.
See UnboundedKafkaSource#generateInitialSplits(int, PipelineOptions) for description
of how the partitions are distributed among the splits.public <KeyT> KafkaIO.Read<KeyT,V> withKeyCoder(Coder<KeyT> keyCoder)
KafkaIO.Read with Coder for key bytes.public <ValueT> KafkaIO.Read<K,ValueT> withValueCoder(Coder<ValueT> valueCoder)
KafkaIO.Read with Coder for value bytes.public KafkaIO.Read<K,V> withConsumerFactoryFn(SerializableFunction<Map<String,Object>,org.apache.kafka.clients.consumer.Consumer<byte[],byte[]>> consumerFactoryFn)
Consumer from consumer configuration.
This is useful for supporting another version of Kafka consumer.
Default is KafkaConsumer.public KafkaIO.Read<K,V> updateConsumerProperties(Map<String,Object> configUpdates)
public KafkaIO.Read<K,V> withMaxNumRecords(long maxNumRecords)
Read.Unbounded.withMaxNumRecords(long).
Mainly used for tests and demo applications.public KafkaIO.Read<K,V> withMaxReadTime(org.joda.time.Duration maxReadTime)
Read.Unbounded.withMaxReadTime(Duration).
Mainly used for tests and demo
applications.Copyright © 2016 The Apache Software Foundation. All rights reserved.