T - public class CryptoAwareSerializerWrapper<T> extends Object implements org.apache.kafka.common.serialization.ExtendedSerializer<T>
Serializer.
It will call the KeyReferenceExtractor and then serialize the data using the underlying serializer| Constructor and Description |
|---|
CryptoAwareSerializerWrapper(org.apache.kafka.common.serialization.Serializer<T> rawSerializer,
KeyReferenceExtractor keyReferenceExtractor,
ThreadLocal<byte[]> keyRefHolder) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
configure(Map<String,?> configs,
boolean isKey) |
byte[] |
serialize(String topic,
org.apache.kafka.common.header.Headers headers,
T data)
Call the KeyReferenceExtractor with the topic and the data and set the result in the kafka header
KafkaCryptoConstants.KEY_REF_HEADER |
byte[] |
serialize(String topic,
T data)
Call the KeyReferenceExtractor with the topic and the data and set the computed value into the ThreadLocal reference holder.
|
public CryptoAwareSerializerWrapper(org.apache.kafka.common.serialization.Serializer<T> rawSerializer, KeyReferenceExtractor keyReferenceExtractor, ThreadLocal<byte[]> keyRefHolder)
rawSerializer - the Serializer to usekeyReferenceExtractor - the KeyReferenceExtractor to usekeyRefHolder - the ThreadLocal to share the keyref (only used in the context of a Kafka Stream)public void configure(Map<String,?> configs, boolean isKey)
configure in interface org.apache.kafka.common.serialization.Serializer<T>public byte[] serialize(String topic, T data)
This method is called in the context of a kafka stream and not in the Kafka Producer
serialize in interface org.apache.kafka.common.serialization.Serializer<T>topic - data - public void close()
close in interface Closeableclose in interface AutoCloseableclose in interface org.apache.kafka.common.serialization.Serializer<T>public byte[] serialize(String topic, org.apache.kafka.common.header.Headers headers, T data)
KafkaCryptoConstants.KEY_REF_HEADER
This method is called by the Kafka Producer
serialize in interface org.apache.kafka.common.serialization.ExtendedSerializer<T>topic - headers - data - Copyright © 2018. All rights reserved.