Class ByteBufferSerializer

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

public class ByteBufferSerializer extends Object implements Serializer<ByteBuffer>
Do not need to flip before call serialize(String, ByteBuffer). For example:
 ByteBufferSerializer serializer = ...; // Create Serializer
 ByteBuffer buffer = ...;               // Allocate ByteBuffer
 buffer.put(data);                      // Put data into buffer, do not need to flip
 serializer.serialize(topic, buffer);   // Serialize buffer
 
  • Constructor Details

    • ByteBufferSerializer

      public ByteBufferSerializer()
  • Method Details

    • serialize

      public byte[] serialize(String topic, ByteBuffer data)
      Description copied from interface: Serializer
      Convert data into a byte array.
      Specified by:
      serialize in interface Serializer<ByteBuffer>
      Parameters:
      topic - topic associated with data
      data - typed data
      Returns:
      serialized bytes