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. It is not necessary to configure standard deserializers supported by
Serdes.- Since:
- 2.3
- Author:
- Gary Russell
-
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) deserialize(String topic, byte[] data) deserialize(String topic, org.apache.kafka.common.header.Headers headers, byte[] data) protected static voidinstantiateAndConfigure(Map<String, ?> configs, boolean isKey, Map<String, org.apache.kafka.common.serialization.Deserializer<?>> delegateMap, String selector, Class<?> clazz) 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. It is not necessary to configure standard deserializers supported bySerdes.- Parameters:
delegates- the map of delegates.
-
-
Method Details
-
configure
- Specified by:
configurein interfaceorg.apache.kafka.common.serialization.Deserializer<Object>
-
createDelegates
-
createInstanceAndConfigure
-
instantiateAndConfigure
-
addDelegate
public void addDelegate(String selector, org.apache.kafka.common.serialization.Deserializer<?> deserializer) -
removeDelegate
-
deserialize
- Specified by:
deserializein interfaceorg.apache.kafka.common.serialization.Deserializer<Object>
-
deserialize
public Object deserialize(String topic, org.apache.kafka.common.header.Headers headers, byte[] 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>
-