Class ParseStringDeserializer<T>
java.lang.Object
org.springframework.kafka.support.serializer.ParseStringDeserializer<T>
- Type Parameters:
T- class of the entity, representing messages
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.kafka.common.serialization.Deserializer<T>
public class ParseStringDeserializer<T>
extends Object
implements org.apache.kafka.common.serialization.Deserializer<T>
Generic
Deserializer for deserialization of entity from
its String representation received from Kafka (a.k.a parsing).- Since:
- 2.5
- Author:
- Alexei Klenin, Gary Russell
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstruct an instance with no parser function; a static method name must be provided in the consumer configKEY_PARSERorVALUE_PARSERproperties.ParseStringDeserializer(BiFunction<String, org.apache.kafka.common.header.Headers, T> parser) Construct an instance with the supplied parser function.ParseStringDeserializer(Function<String, T> parser) Construct an instance with the supplied parser function. -
Method Summary
Modifier and TypeMethodDescriptionvoiddeserialize(String topic, byte[] data) deserialize(String topic, org.apache.kafka.common.header.Headers headers, byte[] data) Get the configured charset.BiFunction<String,org.apache.kafka.common.header.Headers, T> Get the configured parser function.voidsetCharset(Charset charset) Set a charset to use when converting byte[] toString.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.kafka.common.serialization.Deserializer
close
-
Field Details
-
KEY_PARSER
Property for the key parser method.- See Also:
-
VALUE_PARSER
Property for the key parser method.- See Also:
-
-
Constructor Details
-
ParseStringDeserializer
public ParseStringDeserializer()Construct an instance with no parser function; a static method name must be provided in the consumer configKEY_PARSERorVALUE_PARSERproperties. -
ParseStringDeserializer
Construct an instance with the supplied parser function. The function may receive null as the input value, for example for a tombstone record in a compacted topic.- Parameters:
parser- the function.
-
ParseStringDeserializer
Construct an instance with the supplied parser function. The function may receive null as the input value, for example for a tombstone record in a compacted topic.- Parameters:
parser- the function.
-
-
Method Details
-
configure
- Specified by:
configurein interfaceorg.apache.kafka.common.serialization.Deserializer<T>
-
deserialize
- Specified by:
deserializein interfaceorg.apache.kafka.common.serialization.Deserializer<T>
-
deserialize
- Specified by:
deserializein interfaceorg.apache.kafka.common.serialization.Deserializer<T>
-
setCharset
Set a charset to use when converting byte[] toString. Default UTF-8.- Parameters:
charset- the charset.
-
getCharset
Get the configured charset.- Returns:
- the charset.
-
getParser
Get the configured parser function.- Returns:
- the function.
-