Skip to content


StateSerdes<K, V> is a factory for creating serializers and deserializers for state stores in Kafka Streams.


import org.apache.kafka.streams.state.StateSerdes
import java.lang.{Long => JLong}
val stateSerdes = StateSerdes.withBuiltinTypes[JLong, String]("topicName", classOf[JLong], classOf[String])
scala> :type stateSerdes

Creating Instance

StateSerdes takes the following to be created:

  • Topic Name
  • Key Serde
  • Value Serde

StateSerdes is created when:

  • CachingWindowStore is requested to initInternal
  • MeteredKeyValueStore is requested to initStoreSerde
  • MeteredSessionStore is requested to initStoreSerde
  • MeteredWindowStore is requested to initStoreSerde
  • withBuiltinTypes


StateSerdes<K, V> withBuiltinTypes(
  String topic,
  Class<K> keyClass,
  Class<V> valueClass)

withBuiltinTypes creates a StateSerdes using Serdes.serdeFrom utility with the given key and value classes.

Back to top