Interface KafkaRecordSerializationSchema<T>
- Type Parameters:
T- the type of values being serialized
- All Superinterfaces:
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.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceContext providing information of the kafka record target location. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> KafkaRecordSerializationSchemaBuilder<T> builder()Creates a default schema builder to provide common building blocks i.e.default voidopen(org.apache.flink.api.common.serialization.SerializationSchema.InitializationContext context, KafkaRecordSerializationSchema.KafkaSinkContext sinkContext) Initialization method for the schema.org.apache.kafka.clients.producer.ProducerRecord<byte[], byte[]> serialize(T element, KafkaRecordSerializationSchema.KafkaSinkContext context, Long timestamp) Serializes given element and returns it as aProducerRecord.
-
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 methodsserialize(Object, KafkaSinkContext, Long)and thus suitable for one time setup work.The provided
SerializationSchema.InitializationContextcan 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 aProducerRecord.- Parameters:
element- element to be serializedcontext- context to possibly determine target partitiontimestamp- timestamp- Returns:
- Kafka
ProducerRecordor null if the given element cannot be serialized
-
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
-