Class DelegatingByTopicSerializer
java.lang.Object
org.springframework.kafka.support.serializer.DelegatingByTopicSerialization<org.apache.kafka.common.serialization.Serializer<?>>
org.springframework.kafka.support.serializer.DelegatingByTopicSerializer
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.apache.kafka.common.serialization.Serializer<Object>
public class DelegatingByTopicSerializer
extends DelegatingByTopicSerialization<org.apache.kafka.common.serialization.Serializer<?>>
implements org.apache.kafka.common.serialization.Serializer<Object>
A
Serializer
that delegates to other serializers based on a topic pattern.- Since:
- 2.8
- Author:
- Gary Russell
-
Field Summary
Fields inherited from class org.springframework.kafka.support.serializer.DelegatingByTopicSerialization
CASE_SENSITIVE, KEY_SERIALIZATION_TOPIC_CONFIG, KEY_SERIALIZATION_TOPIC_DEFAULT, VALUE_SERIALIZATION_TOPIC_CONFIG, VALUE_SERIALIZATION_TOPIC_DEFAULT
-
Constructor Summary
ConstructorDescriptionConstruct an instance that will be configured inconfigure(Map, boolean)
with producer propertiesDelegatingByTopicSerialization.VALUE_SERIALIZATION_TOPIC_CONFIG
andDelegatingByTopicSerialization.KEY_SERIALIZATION_TOPIC_CONFIG
.DelegatingByTopicSerializer
(Map<Pattern, org.apache.kafka.common.serialization.Serializer<?>> delegates, org.apache.kafka.common.serialization.Serializer<?> defaultDelegate) Construct an instance with the supplied mapping of topic patterns to delegate serializers. -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected org.apache.kafka.common.serialization.Serializer<?>
configureDelegate
(Map<String, ?> configs, boolean isKey, org.apache.kafka.common.serialization.Serializer<?> delegate) Configure the delegate.protected boolean
isInstance
(Object instance) Return true if this object is an instance of T.byte[]
byte[]
Methods inherited from class org.springframework.kafka.support.serializer.DelegatingByTopicSerialization
addDelegate, build, buildDefault, close, findDelegate, instantiateAndConfigure, removeDelegate, setCaseSensitive
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.kafka.common.serialization.Serializer
close
-
Constructor Details
-
DelegatingByTopicSerializer
public DelegatingByTopicSerializer()Construct an instance that will be configured inconfigure(Map, boolean)
with producer propertiesDelegatingByTopicSerialization.VALUE_SERIALIZATION_TOPIC_CONFIG
andDelegatingByTopicSerialization.KEY_SERIALIZATION_TOPIC_CONFIG
. -
DelegatingByTopicSerializer
public DelegatingByTopicSerializer(Map<Pattern, org.apache.kafka.common.serialization.Serializer<?>> delegates, org.apache.kafka.common.serialization.Serializer<?> defaultDelegate) Construct an instance with the supplied mapping of topic patterns to delegate serializers.- Parameters:
delegates
- the map of delegates.defaultDelegate
- the default to use when no topic name match.
-
-
Method Details
-
configure
- Specified by:
configure
in interfaceorg.apache.kafka.common.serialization.Serializer<Object>
- Overrides:
configure
in classDelegatingByTopicSerialization<org.apache.kafka.common.serialization.Serializer<?>>
-
configureDelegate
protected org.apache.kafka.common.serialization.Serializer<?> configureDelegate(Map<String, ?> configs, boolean isKey, org.apache.kafka.common.serialization.Serializer<?> delegate) Description copied from class:DelegatingByTopicSerialization
Configure the delegate.- Specified by:
configureDelegate
in classDelegatingByTopicSerialization<org.apache.kafka.common.serialization.Serializer<?>>
- Parameters:
configs
- the configs.isKey
- true if this is for keys.delegate
- the delegate.- Returns:
- the delegate.
-
isInstance
Description copied from class:DelegatingByTopicSerialization
Return true if this object is an instance of T.- Specified by:
isInstance
in classDelegatingByTopicSerialization<org.apache.kafka.common.serialization.Serializer<?>>
- Parameters:
instance
- the delegate.- Returns:
- true if a T.
-
serialize
- Specified by:
serialize
in interfaceorg.apache.kafka.common.serialization.Serializer<Object>
-
serialize
- Specified by:
serialize
in interfaceorg.apache.kafka.common.serialization.Serializer<Object>
-