Interface KafkaRecordSerializationSchema<T>

Type Parameters:
T - the type of values being serialized
All Superinterfaces:
Serializable

@PublicEvolving public interface KafkaRecordSerializationSchema<T> extends Serializable
A serialization schema which defines how to convert a value of type T to ProducerRecord. KafkaDatasetFacetProvider can be implemented to provide Kafka specific lineage metadata, while TypeDatasetFacetProvider can be implemented to provide lineage metadata with type information.
  • Method Details

    • open

      default void open(org.apache.flink.api.common.serialization.SerializationSchema.InitializationContext context, KafkaRecordSerializationSchema.KafkaSinkContext sinkContext) throws Exception
      Initialization method for the schema. It is called before the actual working methods serialize(Object, KafkaSinkContext, Long) and thus suitable for one time setup work.

      The provided SerializationSchema.InitializationContext can be used to access additional features such as e.g. registering user metrics.

      Parameters:
      context - Contextual information that can be used during initialization.
      sinkContext - runtime information i.e. partitions, subtaskId
      Throws:
      Exception
    • serialize

      @Nullable org.apache.kafka.clients.producer.ProducerRecord<byte[],byte[]> serialize(T element, KafkaRecordSerializationSchema.KafkaSinkContext context, Long timestamp)
      Serializes given element and returns it as a ProducerRecord.
      Parameters:
      element - element to be serialized
      context - context to possibly determine target partition
      timestamp - timestamp
      Returns:
      Kafka ProducerRecord or null if the given element cannot be serialized
    • builder

      static <T> KafkaRecordSerializationSchemaBuilder<T> builder()
      Creates a default schema builder to provide common building blocks i.e. key serialization, value serialization, partitioning.
      Type Parameters:
      T - type of incoming elements
      Returns:
      KafkaRecordSerializationSchemaBuilder