Flink Quickstart Archetype

Create a Flink streaming application using a maven archetype for Flink on Cloudera.

The Flink quickstart archetype can be used to quickly build a basic Flink streaming project.
  1. Perform the following commands to create the archetype locally:
    git clone https://github.com/cloudera/flink-tutorials
    cd flink-quickstart-archetype
    mvn install
    cd ..

    The following entry should be seen in your local catalog:

    cat ~/.m2/repository/archetype-catalog.xml
  2. Generate the project skeleton with the following commands:
    mvn archetype:generate \
          -DarchetypeGroupId=com.cloudera.flink \
          -DarchetypeArtifactId=flink-quickstart-archetype \
  3. Provide basic information about the streaming application.
    You can choose to customize configurations yourself or use automatically generated information.
    • To use automatically generated information, press Enter.
    • If you choose to customize configuration, set the following properties:
      Define value for property 'groupId': com.cloudera.flink
                                      Define value for property 'artifactId': sample-project
                                      Define value for property 'version' 1.0-SNAPSHOT: :
                                      Define value for property 'package' com.cloudera.flink: :
                                      Confirm properties configuration:
                                      groupId: com.cloudera.flink
                                      artifactId: sample-project
                                      version: 1.0-SNAPSHOT
                                      package: com.cloudera.flink
                                      Y: :
    The generated project will look like this:
    ├── pom.xml
    └── src
        └── main
            ├── java
            │   └── com
            │       └── cloudera
            │           └── flink
            │               └── StreamingJob.java
            └── resources
                └── log4j.properties 
  4. Open StreamingJob.java file.
    The archetype application will look like this:
    public class StreamingJob {
    	public static void main(String[] args) throws Exception {
    		final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    		DataStream<Integer> ds = env.fromElements(1,2,3,4);
    		env.execute("Flink Streaming Java API Skeleton");
  5. Customize the archetype application by adding source, stream transformation and sink to the Datastream class.
  6. Execute the application with env.execute command.
You have built your Flink streaming project.
You can further develop your application, or you can run the Flink application archetype.