Serdes

Serdes is a Scala object that contains the implicit conversions with serializers and deserializers for known Scala and Java types and fromFn to create a new Serde[T] (from T or (String, T)).

You should import Serdes to use the implicit conversions in a Scala application that uses the Kafka Streams library.

import org.apache.kafka.streams.scala.Serdes._

You should also use Serdes when defining StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG and StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG.

import org.apache.kafka.streams.scala.Serdes._
Serdes.String.getClass.getName
Table 1. Implicit Conversions
Name Serde

ByteArray

Serde[Array[Byte]]

Bytes

Serde[org.apache.kafka.common.utils.Bytes]

Double

Serde[Double]

Float

Serde[Float]

Integer

Serde[Int]

JavaDouble

Serde[java.lang.Double]

JavaFloat

Serde[java.lang.Float]

JavaInteger

Serde[java.lang.Integer]

JavaLong

Serde[java.lang.Long]

Long

Serde[Long]

String

Serde[String]

sessionWindowedSerde[T]

WindowedSerdes.SessionWindowedSerde[T]

timeWindowedSerde[T]

WindowedSerdes.TimeWindowedSerde[T]

fromFn Method

fromFn[T >: Null](
  serializer: T => Array[Byte],
  deserializer: Array[Byte] => Option[T]): Serde[T]
fromFn[T >: Null](
  serializer: (String, T) => Array[Byte],
  deserializer: (String, Array[Byte]) => Option[T]): Serde[T]

fromFn…​FIXME

Note
fromFn is used when…​FIXME

results matching ""

    No results matching ""