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 SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()voidGet the configured charset.booleanGet the addTypeInfo property.byte[]byte[]voidsetAddTypeInfo(boolean addTypeInfo) Set to false to disable adding type info headers.voidsetCharset(Charset charset) Set a charset to use when convertingStringto byte[].
- 
Field Details- 
ADD_TYPE_INFO_HEADERSKafka config property for enabling/disabling adding type headers.- See Also:
 
- 
KEY_TYPE
- 
VALUE_TYPE
 
- 
- 
Constructor Details- 
ToStringSerializerpublic ToStringSerializer()
 
- 
- 
Method Details- 
configure
- 
serialize
- 
serialize
- 
closepublic void close()- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- org.apache.kafka.common.serialization.Serializer<T>
 
- 
isAddTypeInfopublic boolean isAddTypeInfo()Get the addTypeInfo property.- Returns:
- the addTypeInfo
 
- 
setAddTypeInfopublic void setAddTypeInfo(boolean addTypeInfo) Set to false to disable adding type info headers.- Parameters:
- addTypeInfo- true to add headers
 
- 
setCharset
- 
getCharset
 
-