Class ErrorHandlingDeserializer<T>
java.lang.Object
org.springframework.kafka.support.serializer.ErrorHandlingDeserializer<T>
- Type Parameters:
 T- class of the entity, representing messages
- All Implemented Interfaces:
 Closeable,AutoCloseable,org.apache.kafka.common.serialization.Deserializer<T>
public class ErrorHandlingDeserializer<T>
extends Object
implements org.apache.kafka.common.serialization.Deserializer<T>
Delegating key/value deserializer that catches exceptions, returning them
 in the headers as serialized java objects.
- Since:
 - 2.2
 - Author:
 - Gary Russell, Artem Bilan, Victor Perez Rey
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringProperty name for the delegate key deserializer.static final StringSupplier for a T when deserialization fails.static final StringProperty name for the validator.static final StringProperty name for the delegate value deserializer.static final StringSupplier for a T when deserialization fails. - 
Constructor Summary
ConstructorsConstructorDescriptionErrorHandlingDeserializer(org.apache.kafka.common.serialization.Deserializer<T> delegate)  - 
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voiddeserialize(String topic, byte[] data) deserialize(String topic, org.apache.kafka.common.header.Headers headers, byte[] data) booleanisForKey()keyDeserializer(boolean isKey) Set to true if this deserializer is to be used as a key deserializer when configuring outside of Kafka.voidsetFailedDeserializationFunction(Function<FailedDeserializationInfo, T> failedDeserializationFunction) Provide an alternative supplying mechanism when deserialization fails.voidsetForKey(boolean isKey) Set to true if this deserializer is to be used as a key deserializer when configuring outside of Kafka.voidsetupDelegate(Map<String, ?> configs, String configKey) voidsetValidator(Validator validator) Set a validator to validate the object after successful deserialization.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
deserialize 
- 
Field Details
- 
KEY_FUNCTION
 - 
VALUE_FUNCTION
 - 
KEY_DESERIALIZER_CLASS
Property name for the delegate key deserializer.- See Also:
 
 - 
VALUE_DESERIALIZER_CLASS
Property name for the delegate value deserializer.- See Also:
 
 - 
VALIDATOR_CLASS
 
 - 
 - 
Constructor Details
- 
ErrorHandlingDeserializer
public ErrorHandlingDeserializer() - 
ErrorHandlingDeserializer
 
 - 
 - 
Method Details
- 
setFailedDeserializationFunction
public void setFailedDeserializationFunction(Function<FailedDeserializationInfo, T> failedDeserializationFunction) Provide an alternative supplying mechanism when deserialization fails.- Parameters:
 failedDeserializationFunction- theFunctionto use.- Since:
 - 2.2.8
 
 - 
isForKey
public boolean isForKey() - 
setForKey
public void setForKey(boolean isKey) Set to true if this deserializer is to be used as a key deserializer when configuring outside of Kafka.- Parameters:
 isKey- true for a key deserializer, false otherwise.- Since:
 - 2.2.3
 
 - 
keyDeserializer
Set to true if this deserializer is to be used as a key deserializer when configuring outside of Kafka.- Parameters:
 isKey- true for a key deserializer, false otherwise.- Returns:
 - this
 - Since:
 - 2.2.3
 
 - 
setValidator
Set a validator to validate the object after successful deserialization. If the validator throws an exception, or returns anErrorswith validation failures, the raw data will be available in any configured error handler.- Parameters:
 validator- the validator to set- Since:
 - 3.1
 
 - 
configure
 - 
setupDelegate
 - 
deserialize
 - 
deserialize
 - 
close
public void close()- Specified by:
 closein interfaceAutoCloseable- Specified by:
 closein interfaceCloseable- Specified by:
 closein interfaceorg.apache.kafka.common.serialization.Deserializer<T>
 
 -