Class StringOrBytesSerializer

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, org.apache.kafka.common.serialization.Serializer<java.lang.Object>

    public class StringOrBytesSerializer
    extends java.lang.Object
    implements org.apache.kafka.common.serialization.Serializer<java.lang.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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void configure​(java.util.Map<java.lang.String,​?> configs, boolean isKey)  
      byte[] serialize​(java.lang.String topic, java.lang.Object data)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apache.kafka.common.serialization.Serializer

        serialize
    • Constructor Detail

      • StringOrBytesSerializer

        public StringOrBytesSerializer()
    • Method Detail

      • configure

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

        public byte[] serialize​(java.lang.String topic,
                                java.lang.Object data)
        Specified by:
        serialize in interface org.apache.kafka.common.serialization.Serializer<java.lang.Object>
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface org.apache.kafka.common.serialization.Serializer<java.lang.Object>