Skip to main content
Ctrl+K
PyFlink 1.20+vvr.11.7.dev0 documentation - Home PyFlink 1.20+vvr.11.7.dev0 documentation - Home
  • API Reference
  • Examples
  • API Reference
  • Examples

Section Navigation

  • PyFlink Table
  • PyFlink DataStream
    • StreamExecutionEnvironment
    • DataStream
    • Functions
    • State
    • Timer
    • Window
    • Checkpoint
    • Side Outputs
    • Asynchronous I/O
    • Connectors
    • Formats
  • PyFlink DataFrame
  • PyFlink Common
  • API Reference
  • PyFlink DataStream
  • Connectors
  • pyflink.datastream.connectors.kafka.KafkaSinkBuilder

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 using set_delivery_guarantee() but keep in mind when using DeliveryGuarantee.EXACTLY_ONCE, one must set the transactional id prefix set_transactional_id_prefix().

Added 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.

previous

pyflink.datastream.connectors.kafka.KafkaSink

next

pyflink.datastream.connectors.kafka.KafkaRecordSerializationSchema

On this page
  • KafkaSinkBuilder

This Page

  • Show Source

Created using Sphinx 7.4.7.

Built with the PyData Sphinx Theme 0.16.1.