Here you’ll learn how to imeplement a Complex Event Processing with Apache Flink.
Maven
Maven or Apache Maven is a tool to build Java projects.
Maven addresses two aspects of building software: first, it describes how software is built, and second, it describes its dependencies.
Install apache-maven:
wget www-eu.apache.org/dist/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.zipUnzip the file and cp to
/opt/directory.sudo cp -r apache-maven-3.5.2/ /opt/Next, modify
.profilefile:export PATH=/opt/apache-maven-3.5.2/bin:$PATH
Apache Flink
Apache Flink is an Open Source Stream Processing Framework written in Java and Scala.
First, create a directory
Apache/Flink.Then, goes to
Apache/Flinkand download apache-flink:wget https://archive.apache.org/dist/flink/flink-1.3.0/flink-1.3.0-bin-hadoop2-scala_2.10.tgzUnzip and start the Flink service:
./flink-1.3.0/bin/start-local.sh
Running an example
NC means OpenBSD netcat, is a package to make connections.
First, set up a listener port:
nc -l 9000Then, run an example:
./flink-1.3.0/bin/flink run flink-1.3.0/examples/streaming/SocketWindowWordCount.jar --port 9000
Create a project
Run this script:
curl https://flink.apache.org/q/quickstart.sh >> createProject.shThen, modify these lines in
createProject.sh:PACKAGE=$1 -DgroupId=$PACKAGE \ -DartifactId=$PACKAGE \ -Dpackage=$PACKAGE \And, run:
bash createProject.sh exampleFlinkYou can get my bash pressing here
Once created, compile and generate
.jarfiles running 1 of these commands on root example dir:mvn clean install -Pbuild-jar mvn clean packageFinally, run this line in the root path of
Apache/Flink:./flink-1.3.0/bin/flink run -c exampleFlink.WordCount exampleFlink/target/exampleFlink-0.1.jar
Creating a Complex Event Processing
CEP (Complex Event Processing) is
First, add this text on
pom.xml<dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-cep_2.10</artifactId> <version>1.3.2</version> </dependency>
