Class StringOrBytesSerializer

java.lang.Object
org.springframework.kafka.support.serializer.StringOrBytesSerializer
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.kafka.common.serialization.Serializer<Object>

public class StringOrBytesSerializer extends Object implements org.apache.kafka.common.serialization.Serializer<Object>
A serializer that can handle byte[], Bytes and String. Convenient when used with one of the Json message converters.
Since:
2.3
Author:
Gary Russell
  • Constructor Details

    • StringOrBytesSerializer

      public StringOrBytesSerializer()
  • Method Details

    • configure

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

      public byte[] serialize(String topic, Object data)
      Specified by:
      serialize in interface org.apache.kafka.common.serialization.Serializer<Object>
    • 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.Serializer<Object>