pyflink.datastream.connectors.kafka.KafkaSinkBuilder#
- class KafkaSinkBuilder[source]#
Builder to construct
KafkaSink
.The following example shows the minimum setup to create a KafkaSink that writes String values to a Kafka topic.
>>> record_serializer = KafkaRecordSerializationSchema.builder() \ ... .set_topic(MY_SINK_TOPIC) \ ... .set_value_serialization_schema(SimpleStringSchema()) \ ... .build() >>> sink = KafkaSink.builder() \ ... .set_bootstrap_servers(MY_BOOTSTRAP_SERVERS) \ ... .set_record_serializer(record_serializer) \ ... .build()
One can also configure different
DeliveryGuarantee
by usingset_delivery_guarantee()
but keep in mind when usingDeliveryGuarantee.EXACTLY_ONCE
, one must set the transactional id prefixset_transactional_id_prefix()
.New in version 1.16.0.
Methods
build
()Constructs the
KafkaSink
with the configured properties.set_bootstrap_servers
(bootstrap_servers)Sets the Kafka bootstrap servers.
set_delivery_guarantee
(delivery_guarantee)Sets the wanted
DeliveryGuarantee
.set_property
(key, value)Sets kafka producer config.
set_record_serializer
(record_serializer)Sets the
KafkaRecordSerializationSchema
that transforms incoming records to kafka producer records.set_transactional_id_prefix
(...)Sets the prefix for all created transactionalIds if
DeliveryGuarantee.EXACTLY_ONCE
is configured.