Class ToStringSerializer<T>
java.lang.Object
org.springframework.kafka.support.serializer.ToStringSerializer<T>
- Type Parameters:
T
- class of the entity, representing messages
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.apache.kafka.common.serialization.Serializer<T>
public class ToStringSerializer<T>
extends Object
implements org.apache.kafka.common.serialization.Serializer<T>
Generic
Serializer
that relies on
Object.toString()
to get serialized representation of the entity.- Since:
- 2.5
- Author:
- Alexei Klenin, Gary Russell
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
Get the configured charset.boolean
Get the addTypeInfo property.byte[]
byte[]
void
setAddTypeInfo
(boolean addTypeInfo) Set to false to disable adding type info headers.void
setCharset
(Charset charset) Set a charset to use when convertingString
to byte[].
-
Field Details
-
ADD_TYPE_INFO_HEADERS
Kafka config property for enabling/disabling adding type headers.- See Also:
-
KEY_TYPE
-
VALUE_TYPE
-
-
Constructor Details
-
ToStringSerializer
public ToStringSerializer()
-
-
Method Details
-
configure
-
serialize
-
serialize
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceorg.apache.kafka.common.serialization.Serializer<T>
-
isAddTypeInfo
public boolean isAddTypeInfo()Get the addTypeInfo property.- Returns:
- the addTypeInfo
-
setAddTypeInfo
public void setAddTypeInfo(boolean addTypeInfo) Set to false to disable adding type info headers.- Parameters:
addTypeInfo
- true to add headers
-
setCharset
-
getCharset
-