Class KafkaIO.Write<K,V>
- All Implemented Interfaces:
Serializable
,HasDisplayData
- Enclosing class:
KafkaIO
PTransform
to write to a Kafka topic with KVs . See KafkaIO
for more
information on usage and configuration.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
ExposesKafkaIO.Write
as an external transform for cross-language usage. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Class
<org.apache.beam.sdk.io.kafka.AutoValue_KafkaIO_Write> Fields inherited from class org.apache.beam.sdk.transforms.PTransform
annotations, displayData, name, resourceHints
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexpand
(PCollection<KV<K, V>> input) Override this method to specify how thisPTransform
should be expanded on the givenInputT
.abstract KafkaIO.WriteRecords
<K, V> void
populateDisplayData
(DisplayData.Builder builder) Register display data for the given transform or component.updateProducerProperties
(Map<String, Object> configUpdates) Deprecated.as of version 2.13.void
validate
(@Nullable PipelineOptions options) Called before running the Pipeline to verify this transform is fully and correctly specified.values()
Writes just the values to Kafka.withBadRecordErrorHandler
(ErrorHandler<BadRecord, ?> badRecordErrorHandler) Configure aErrorHandler.BadRecordErrorHandler
for sending records to if they fail to serialize when being sent to Kafka.withBootstrapServers
(String bootstrapServers) Wrapper method overKafkaIO.WriteRecords.withBootstrapServers(String)
, used to keep the compatibility with old API based on KV type of element.withConsumerFactoryFn
(SerializableFunction<Map<String, Object>, ? extends Consumer<?, ?>> consumerFactoryFn) Wrapper method overKafkaIO.WriteRecords.withConsumerFactoryFn(SerializableFunction)
, used to keep the compatibility with old API based on KV type of element.Wrapper method overKafkaIO.WriteRecords.withEOS(int, String)
, used to keep the compatibility with old API based on KV type of element.Creates and sets the Application Default Credentials for a Kafka producer.Wrapper method overKafkaIO.WriteRecords.withInputTimestamp()
, used to keep the compatibility with old API based on KV type of element.withKeySerializer
(Class<? extends Serializer<K>> keySerializer) Wrapper method overKafkaIO.WriteRecords.withKeySerializer(Class)
, used to keep the compatibility with old API based on KV type of element.withProducerConfigUpdates
(Map<String, Object> configUpdates) Update configuration for the producer.withProducerFactoryFn
(SerializableFunction<Map<String, Object>, Producer<K, V>> producerFactoryFn) Wrapper method overKafkaIO.WriteRecords.withProducerFactoryFn(SerializableFunction)
, used to keep the compatibility with old API based on KV type of element.withPublishTimestampFunction
(KafkaPublishTimestampFunction<KV<K, V>> timestampFunction) Deprecated.useKafkaIO.WriteRecords
andProducerRecords
to set publish timestamp.Wrapper method overKafkaIO.WriteRecords.withTopic(String)
, used to keep the compatibility with old API based on KV type of element.withValueSerializer
(Class<? extends Serializer<V>> valueSerializer) Wrapper method overKafkaIO.WriteRecords.withValueSerializer(Class)
, used to keep the compatibility with old API based on KV type of element.Methods inherited from class org.apache.beam.sdk.transforms.PTransform
addAnnotation, compose, compose, getAdditionalInputs, getAnnotations, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, setDisplayData, setResourceHints, toString, validate
-
Field Details
-
AUTOVALUE_CLASS
-
-
Constructor Details
-
Write
public Write()
-
-
Method Details
-
getWriteRecordsTransform
-
withBootstrapServers
Wrapper method overKafkaIO.WriteRecords.withBootstrapServers(String)
, used to keep the compatibility with old API based on KV type of element. -
withTopic
Wrapper method overKafkaIO.WriteRecords.withTopic(String)
, used to keep the compatibility with old API based on KV type of element. -
withKeySerializer
Wrapper method overKafkaIO.WriteRecords.withKeySerializer(Class)
, used to keep the compatibility with old API based on KV type of element. -
withValueSerializer
Wrapper method overKafkaIO.WriteRecords.withValueSerializer(Class)
, used to keep the compatibility with old API based on KV type of element. -
withProducerFactoryFn
public KafkaIO.Write<K,V> withProducerFactoryFn(SerializableFunction<Map<String, Object>, Producer<K, V>> producerFactoryFn) Wrapper method overKafkaIO.WriteRecords.withProducerFactoryFn(SerializableFunction)
, used to keep the compatibility with old API based on KV type of element. -
withInputTimestamp
Wrapper method overKafkaIO.WriteRecords.withInputTimestamp()
, used to keep the compatibility with old API based on KV type of element. -
withPublishTimestampFunction
@Deprecated public KafkaIO.Write<K,V> withPublishTimestampFunction(KafkaPublishTimestampFunction<KV<K, V>> timestampFunction) Deprecated.useKafkaIO.WriteRecords
andProducerRecords
to set publish timestamp.Wrapper method overKafkaIO.WriteRecords.withPublishTimestampFunction(KafkaPublishTimestampFunction)
, used to keep the compatibility with old API based on KV type of element. -
withEOS
Wrapper method overKafkaIO.WriteRecords.withEOS(int, String)
, used to keep the compatibility with old API based on KV type of element. -
withConsumerFactoryFn
public KafkaIO.Write<K,V> withConsumerFactoryFn(SerializableFunction<Map<String, Object>, ? extends Consumer<?, ?>> consumerFactoryFn) Wrapper method overKafkaIO.WriteRecords.withConsumerFactoryFn(SerializableFunction)
, used to keep the compatibility with old API based on KV type of element. -
updateProducerProperties
Deprecated.as of version 2.13. UsewithProducerConfigUpdates(Map)
instead.Adds the given producer properties, overriding old values of properties with the same key. -
withProducerConfigUpdates
Update configuration for the producer. Note that the default producer properties will not be completely overridden. This method only updates the value which has the same key.By default, the producer uses the configuration from
KafkaIO.WriteRecords.DEFAULT_PRODUCER_PROPERTIES
. -
withBadRecordErrorHandler
public KafkaIO.Write<K,V> withBadRecordErrorHandler(ErrorHandler<BadRecord, ?> badRecordErrorHandler) Configure aErrorHandler.BadRecordErrorHandler
for sending records to if they fail to serialize when being sent to Kafka. -
withGCPApplicationDefaultCredentials
Creates and sets the Application Default Credentials for a Kafka producer. This allows the consumer to be authenticated with a Google Kafka Server using OAuth. -
expand
Description copied from class:PTransform
Override this method to specify how thisPTransform
should be expanded on the givenInputT
.NOTE: This method should not be called directly. Instead apply the
PTransform
should be applied to theInputT
using theapply
method.Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).
- Specified by:
expand
in classPTransform<PCollection<KV<K,
V>>, PDone>
-
validate
Description copied from class:PTransform
Called before running the Pipeline to verify this transform is fully and correctly specified.By default, does nothing.
- Overrides:
validate
in classPTransform<PCollection<KV<K,
V>>, PDone>
-
populateDisplayData
Description copied from class:PTransform
Register display data for the given transform or component.populateDisplayData(DisplayData.Builder)
is invoked by Pipeline runners to collect display data viaDisplayData.from(HasDisplayData)
. Implementations may callsuper.populateDisplayData(builder)
in order to register display data in the current namespace, but should otherwise usesubcomponent.populateDisplayData(builder)
to use the namespace of the subcomponent.By default, does not register any display data. Implementors may override this method to provide their own display data.
- Specified by:
populateDisplayData
in interfaceHasDisplayData
- Overrides:
populateDisplayData
in classPTransform<PCollection<KV<K,
V>>, PDone> - Parameters:
builder
- The builder to populate with display data.- See Also:
-
values
Writes just the values to Kafka. This is useful for writing collections of values rather thankKV
s.
-