Get Started Free
course: Building Apache Flink® Applications in Java

Working with Keyed State in Flink

5 min
Wade Waldron

Wade Waldron

Staff Software Practice Lead

Working with Keyed State in Flink


One of the powerful features of Flink is its ability to maintain state in a datastream. This state can be kept local to the operation being performed which can improve performance by eliminating network hops. In this video, we'll introduce keyed state in Flink and show you how you can use it to maintain state across messages and even windows.


  • Keyed State
  • Value/List/Map State
  • Reducing State/Aggregating State
  • Descriptors
  • Loading/Updating State



private ValueStateDescriptor<MyClass> descriptor;

public void open(Configuration parameters) {
	descriptor = new ValueStateDescriptor<>(

Accessing/Updating State

public void process(...) {
	ValueState<MyClass> state = context
	MyClass value = state.value();

	if(value == null) {
	} else {



Use the promo code FLINKJAVA101 to get $25 of free Confluent Cloud usage

Be the first to get updates and new content

We will only share developer content and updates, including notifications when new content is added. We will never send you sales emails. 🙂 By subscribing, you understand we will process your personal information in accordance with our Privacy Statement.