T
- the type of values being serialized@PublicEvolving public interface KafkaRecordSerializationSchema<T> extends Serializable
T
to ProducerRecord
.Modifier and Type | Interface and Description |
---|---|
static interface |
KafkaRecordSerializationSchema.KafkaSinkContext
Context providing information of the kafka record target location.
|
Modifier and Type | Method and Description |
---|---|
static <T> KafkaRecordSerializationSchemaBuilder<T> |
builder()
Creates a default schema builder to provide common building blocks i.e.
|
default void |
open(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 a
ProducerRecord . |
default void open(SerializationSchema.InitializationContext context, KafkaRecordSerializationSchema.KafkaSinkContext sinkContext) throws Exception
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.
context
- Contextual information that can be used during initialization.sinkContext
- runtime information i.e. partitions, subtaskIdException
@Nullable org.apache.kafka.clients.producer.ProducerRecord<byte[],byte[]> serialize(T element, KafkaRecordSerializationSchema.KafkaSinkContext context, Long timestamp)
ProducerRecord
.element
- element to be serializedcontext
- context to possibly determine target partitiontimestamp
- timestampProducerRecord
or null if the given element cannot be serializedstatic <T> KafkaRecordSerializationSchemaBuilder<T> builder()
T
- type of incoming elementsKafkaRecordSerializationSchemaBuilder
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.