Class DelegatingDeserializer
java.lang.Object
org.springframework.kafka.support.serializer.DelegatingDeserializer
- All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.kafka.common.serialization.Deserializer<Object>
public class DelegatingDeserializer
extends Object
implements org.apache.kafka.common.serialization.Deserializer<Object>
A
Deserializer that delegates to other deserializers based on a serialization
selector header. The selector header is supplied by the producer of each record; if it
does not match a configured delegate, the raw data is returned. To deserialize the
standard types for which the DelegatingSerializer sets the selector to the class
name, configure delegates with those class names as selectors.- Since:
- 2.3
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct an instance that will be configured inconfigure(Map, boolean)with consumer propertiesDelegatingSerializer.KEY_SERIALIZATION_SELECTOR_CONFIGandDelegatingSerializer.VALUE_SERIALIZATION_SELECTOR_CONFIG.DelegatingDeserializer(Map<String, org.apache.kafka.common.serialization.Deserializer<?>> delegates) Construct an instance with the supplied mapping of selectors to delegate deserializers. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDelegate(String selector, org.apache.kafka.common.serialization.Deserializer<?> deserializer) voidclose()voidcreateDelegates(String mappings, Map<String, ?> configs, boolean isKey) protected static voidcreateInstanceAndConfigure(Map<String, ?> configs, boolean isKey, Map<String, org.apache.kafka.common.serialization.Deserializer<?>> delegateMap, String selector, String className) @Nullable Objectdeserialize(String topic, byte @Nullable [] data) @Nullable Objectdeserialize(String topic, org.apache.kafka.common.header.Headers headers, byte @Nullable [] data) @Nullable Objectdeserialize(String topic, org.apache.kafka.common.header.Headers headers, @Nullable ByteBuffer data) protected static voidinstantiateAndConfigure(Map<String, ?> configs, boolean isKey, Map<String, org.apache.kafka.common.serialization.Deserializer<?>> delegateMap, String selector, Class<?> clazz) @Nullable org.apache.kafka.common.serialization.Deserializer<?> removeDelegate(String selector)
-
Constructor Details
-
DelegatingDeserializer
public DelegatingDeserializer()Construct an instance that will be configured inconfigure(Map, boolean)with consumer propertiesDelegatingSerializer.KEY_SERIALIZATION_SELECTOR_CONFIGandDelegatingSerializer.VALUE_SERIALIZATION_SELECTOR_CONFIG. -
DelegatingDeserializer
public DelegatingDeserializer(Map<String, org.apache.kafka.common.serialization.Deserializer<?>> delegates) Construct an instance with the supplied mapping of selectors to delegate deserializers. The selector must be supplied in theDelegatingSerializer.KEY_SERIALIZATION_SELECTOR_CONFIGandDelegatingSerializer.VALUE_SERIALIZATION_SELECTOR_CONFIGheaders.- Parameters:
delegates- the map of delegates.
-
-
Method Details
-
configure
-
createDelegates
-
createInstanceAndConfigure
-
instantiateAndConfigure
-
addDelegate
public void addDelegate(String selector, org.apache.kafka.common.serialization.Deserializer<?> deserializer) -
removeDelegate
public @Nullable org.apache.kafka.common.serialization.Deserializer<?> removeDelegate(String selector) -
deserialize
-
deserialize
-
deserialize
public @Nullable Object deserialize(String topic, org.apache.kafka.common.header.Headers headers, @Nullable ByteBuffer data) - Specified by:
deserializein interfaceorg.apache.kafka.common.serialization.Deserializer<Object>
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceorg.apache.kafka.common.serialization.Deserializer<Object>
-