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
  • Field Details

    • KEY_FUNCTION

      public static final String KEY_FUNCTION
      Supplier for a T when deserialization fails.
      See Also:
    • VALUE_FUNCTION

      public static final String VALUE_FUNCTION
      Supplier for a T when deserialization fails.
      See Also:
    • KEY_DESERIALIZER_CLASS

      public static final String KEY_DESERIALIZER_CLASS
      Property name for the delegate key deserializer.
      See Also:
    • VALUE_DESERIALIZER_CLASS

      public static final String VALUE_DESERIALIZER_CLASS
      Property name for the delegate value deserializer.
      See Also:
  • Constructor Details

    • ErrorHandlingDeserializer

      public ErrorHandlingDeserializer()
    • ErrorHandlingDeserializer

      public ErrorHandlingDeserializer(org.apache.kafka.common.serialization.Deserializer<T> delegate)
  • Method Details

    • setFailedDeserializationFunction

      public void setFailedDeserializationFunction(Function<FailedDeserializationInfo,T> failedDeserializationFunction)
      Provide an alternative supplying mechanism when deserialization fails.
      Parameters:
      failedDeserializationFunction - the Function to 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

      public ErrorHandlingDeserializer<T> keyDeserializer(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.
      Returns:
      this
      Since:
      2.2.3
    • configure

      public void configure(Map<String,?> configs, boolean isKey)
      Specified by:
      configure in interface org.apache.kafka.common.serialization.Deserializer<T>
    • setupDelegate

      public void setupDelegate(Map<String,?> configs, String configKey)
    • deserialize

      public T deserialize(String topic, byte[] data)
      Specified by:
      deserialize in interface org.apache.kafka.common.serialization.Deserializer<T>
    • deserialize

      public T deserialize(String topic, org.apache.kafka.common.header.Headers headers, byte[] data)
      Specified by:
      deserialize in interface org.apache.kafka.common.serialization.Deserializer<T>
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.apache.kafka.common.serialization.Deserializer<T>