Ctrl+K
Logo image Logo image

Site Navigation

  • API Reference
  • Examples

Site Navigation

  • API Reference
  • Examples

Section Navigation

  • PyFlink Table
  • PyFlink DataStream
    • StreamExecutionEnvironment
    • DataStream
    • Functions
    • State
    • Timer
    • Window
    • Checkpoint
    • Side Outputs
    • Connectors
    • Formats
  • PyFlink Common

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().

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.

previous

pyflink.datastream.connectors.kafka.KafkaSink

next

pyflink.datastream.connectors.kafka.KafkaRecordSerializationSchema

On this page
  • KafkaSinkBuilder
Show Source

Created using Sphinx 5.3.0.