This documentation is for an out-of-date version of Apache Flink Stateful Functions. We recommend you use the latest stable version.

Project Setup


You can quickly get started building a Stateful Functions applications by adding the statefun-sdk to an existing project or using the provided maven archetype.


Maven Archetype

$ mvn archetype:generate \
    -DarchetypeGroupId=org.apache.flink \
    -DarchetypeArtifactId=statefun-quickstart \

This allows you to name your newly created project. It will interactively ask you for the groupId, artifactId, and package name. There will be a new directory with the same name as your artifact id.

$ tree statefun-quickstart/
  ├── Dockerfile
  ├── pom.xml
  └── src
      └── main
          ├── java
          │   └── org
          │       └── apache
          |            └── flink
          │             └── statefun
          │              └──
          └── resources
              └── META-INF
                └── services
                  └── org.apache.flink.statefun.sdk.spi.StatefulFunctionModule

The project contains four files:

  • pom.xml: A pom file with the basic dependencies to start building a Stateful Functions application.
  • The entry point for the application.
  • org.apache.flink.statefun.sdk.spi.StatefulFunctionModule: A service entry for the runtime to find the module.
  • Dockerfile: A Dockerfile to quickly build a Stateful Functions image ready to deploy.

We recommend you import this project into your IDE to develop and test it. IntelliJ IDEA supports Maven projects out of the box. If you use Eclipse, the m2e plugin allows to import Maven projects. Some Eclipse bundles include that plugin by default, others require you to install it manually.

Build Project

If you want to build/package your project, go to your project directory and run the mvn clean package command. You will find a JAR file that contains your application, plus any libraries that you may have added as dependencies to the application: target/<artifact-id>-<version>.jar.