Skip to content

Commit be833d0

Browse files
committed
Java application
1 parent 68aa1ff commit be833d0

File tree

3 files changed

+208
-1
lines changed

3 files changed

+208
-1
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
.idea
2-
**/node_modules
2+
**/node_modules
3+
**/target
4+
*.iml
5+
*.zip
6+
**/dependency-reduced-pom.xml
7+
**/cdk.out
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.amazon.aws.blog</groupId>
6+
<artifactId>kinesis-analytics-application</artifactId>
7+
<version>1.0.0</version>
8+
<packaging>jar</packaging>
9+
10+
<name>Amazon Kinesis Data Analytics Sample Job</name>
11+
12+
<properties>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<flink.version>1.13.2</flink.version>
15+
<target.java.version>11</target.java.version>
16+
<scala.binary.version>2.12</scala.binary.version>
17+
<aws.kda.version>1.2.0</aws.kda.version>
18+
<log4j.version>2.17.2</log4j.version>
19+
<maven.compiler.source>${target.java.version}</maven.compiler.source>
20+
<maven.compiler.target>${target.java.version}</maven.compiler.target>
21+
</properties>
22+
23+
<dependencies>
24+
<!-- Apache Flink dependencies -->
25+
<!-- These dependencies are provided, because they should not be packaged into the JAR file. -->
26+
<dependency>
27+
<groupId>com.amazonaws</groupId>
28+
<artifactId>aws-kinesisanalytics-runtime</artifactId>
29+
<version>${aws.kda.version}</version>
30+
<scope>provided</scope>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.apache.flink</groupId>
34+
<artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
35+
<version>${flink.version}</version>
36+
<scope>provided</scope>
37+
</dependency>
38+
39+
<!-- Add connector dependencies here. They must be in the default scope (compile). -->
40+
<dependency>
41+
<groupId>org.apache.flink</groupId>
42+
<artifactId>flink-connector-kinesis_${scala.binary.version}</artifactId>
43+
<version>${flink.version}</version>
44+
</dependency>
45+
46+
<dependency>
47+
<groupId>org.apache.logging.log4j</groupId>
48+
<artifactId>log4j-slf4j-impl</artifactId>
49+
<version>${log4j.version}</version>
50+
</dependency>
51+
52+
<dependency>
53+
<groupId>org.apache.logging.log4j</groupId>
54+
<artifactId>log4j-api</artifactId>
55+
<version>${log4j.version}</version>
56+
</dependency>
57+
58+
<dependency>
59+
<groupId>org.apache.logging.log4j</groupId>
60+
<artifactId>log4j-core</artifactId>
61+
<version>${log4j.version}</version>
62+
</dependency>
63+
</dependencies>
64+
65+
<build>
66+
<plugins>
67+
68+
<!-- Java Compiler -->
69+
<plugin>
70+
<groupId>org.apache.maven.plugins</groupId>
71+
<artifactId>maven-compiler-plugin</artifactId>
72+
<version>3.1</version>
73+
<configuration>
74+
<source>${target.java.version}</source>
75+
<target>${target.java.version}</target>
76+
</configuration>
77+
</plugin>
78+
79+
<!-- We use the maven-shade plugin to create a fat jar that contains all necessary dependencies. -->
80+
<!-- Change the value of <mainClass>...</mainClass> if your program entry point changes. -->
81+
<plugin>
82+
<groupId>org.apache.maven.plugins</groupId>
83+
<artifactId>maven-shade-plugin</artifactId>
84+
<version>3.1.1</version>
85+
<executions>
86+
<!-- Run shade goal on package phase -->
87+
<execution>
88+
<phase>package</phase>
89+
<goals>
90+
<goal>shade</goal>
91+
</goals>
92+
<configuration>
93+
<artifactSet>
94+
<excludes>
95+
<exclude>org.apache.flink:flink-shaded-force-shading</exclude>
96+
<exclude>com.google.code.findbugs:jsr305</exclude>
97+
<exclude>org.slf4j:*</exclude>
98+
<exclude>org.apache.logging.log4j:*</exclude>
99+
</excludes>
100+
</artifactSet>
101+
<filters>
102+
<filter>
103+
<!-- Do not copy the signatures in the META-INF folder.
104+
Otherwise, this might cause SecurityExceptions when using the JAR. -->
105+
<artifact>*:*</artifact>
106+
<excludes>
107+
<exclude>META-INF/*.SF</exclude>
108+
<exclude>META-INF/*.DSA</exclude>
109+
<exclude>META-INF/*.RSA</exclude>
110+
</excludes>
111+
</filter>
112+
</filters>
113+
<transformers>
114+
<transformer
115+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
116+
<mainClass>com.amazon.aws.blog.KinesisAnalyticsApplication</mainClass>
117+
</transformer>
118+
</transformers>
119+
</configuration>
120+
</execution>
121+
</executions>
122+
</plugin>
123+
</plugins>
124+
125+
<pluginManagement>
126+
<plugins>
127+
128+
<!-- This improves the out-of-the-box experience in Eclipse by resolving some warnings. -->
129+
<plugin>
130+
<groupId>org.eclipse.m2e</groupId>
131+
<artifactId>lifecycle-mapping</artifactId>
132+
<version>1.0.0</version>
133+
<configuration>
134+
<lifecycleMappingMetadata>
135+
<pluginExecutions>
136+
<pluginExecution>
137+
<pluginExecutionFilter>
138+
<groupId>org.apache.maven.plugins</groupId>
139+
<artifactId>maven-shade-plugin</artifactId>
140+
<versionRange>[3.1.1,)</versionRange>
141+
<goals>
142+
<goal>shade</goal>
143+
</goals>
144+
</pluginExecutionFilter>
145+
<action>
146+
<ignore/>
147+
</action>
148+
</pluginExecution>
149+
<pluginExecution>
150+
<pluginExecutionFilter>
151+
<groupId>org.apache.maven.plugins</groupId>
152+
<artifactId>maven-compiler-plugin</artifactId>
153+
<versionRange>[3.1,)</versionRange>
154+
<goals>
155+
<goal>testCompile</goal>
156+
<goal>compile</goal>
157+
</goals>
158+
</pluginExecutionFilter>
159+
<action>
160+
<ignore/>
161+
</action>
162+
</pluginExecution>
163+
</pluginExecutions>
164+
</lifecycleMappingMetadata>
165+
</configuration>
166+
</plugin>
167+
</plugins>
168+
</pluginManagement>
169+
</build>
170+
</project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.amazon.aws.blog;
2+
3+
import com.amazonaws.services.kinesisanalytics.runtime.KinesisAnalyticsRuntime;
4+
import org.apache.flink.api.common.serialization.SimpleStringSchema;
5+
import org.apache.flink.streaming.api.datastream.DataStreamSource;
6+
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
7+
import org.apache.flink.streaming.connectors.kinesis.FlinkKinesisConsumer;
8+
9+
import java.util.Map;
10+
import java.util.Properties;
11+
12+
public class KinesisAnalyticsApplication {
13+
14+
public static void main(String[] args) throws Exception {
15+
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
16+
Map<String, Properties> applicationProperties = KinesisAnalyticsRuntime.getApplicationProperties();
17+
Properties kinesisReaderProperties = applicationProperties.get("KinesisReader");
18+
19+
DataStreamSource<String> eventSourceStream = env.addSource(new FlinkKinesisConsumer<>(
20+
// read events from the Kinesis stream passed in as a parameter
21+
kinesisReaderProperties.getProperty("input.stream.name"),
22+
// deserialize events here
23+
new SimpleStringSchema(),
24+
kinesisReaderProperties
25+
));
26+
27+
// Print incoming messages to the console Sink
28+
eventSourceStream.print();
29+
env.execute(KinesisAnalyticsApplication.class.getName());
30+
}
31+
32+
}

0 commit comments

Comments
 (0)