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
ConstructorDescriptionConstruct an instance that will be configured inconfigure(Map, boolean)
with consumer propertiesDelegatingSerializer.KEY_SERIALIZATION_SELECTOR_CONFIG
andDelegatingSerializer.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 TypeMethodDescriptionvoid
addDelegate
(String selector, org.apache.kafka.common.serialization.Deserializer<?> deserializer) void
close()
void
createDelegates
(String mappings, Map<String, ?> configs, boolean isKey) protected static void
createInstanceAndConfigure
(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 void
instantiateAndConfigure
(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_CONFIG
andDelegatingSerializer.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_CONFIG
andDelegatingSerializer.VALUE_SERIALIZATION_SELECTOR_CONFIG
headers. It is not necessary to configure standard deserializers supported bySerdes
.- Parameters:
delegates
- the map of delegates.
-
-
Method Details
-
configure
- Specified by:
configure
in 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:
deserialize
in interfaceorg.apache.kafka.common.serialization.Deserializer<Object>
-
deserialize
public Object deserialize(String topic, org.apache.kafka.common.header.Headers headers, byte[] data) - Specified by:
deserialize
in interfaceorg.apache.kafka.common.serialization.Deserializer<Object>
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceorg.apache.kafka.common.serialization.Deserializer<Object>
-