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 typeTtoProducerRecord.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceKafkaRecordSerializationSchema.KafkaSinkContextContext providing information of the kafka record target location.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static <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 Detail
-
open
default void open(org.apache.flink.api.common.serialization.SerializationSchema.InitializationContext context, KafkaRecordSerializationSchema.KafkaSinkContext sinkContext) throws ExceptionInitialization 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
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
-
-