Skip to content

Commit 05d2f24

Browse files
authored
Merge pull request eugenp#7846 from laurentiud/master
BAEL-3165 Integrate Kinesis with Spring Binder
2 parents 0196549 + 42ef916 commit 05d2f24

File tree

5 files changed

+106
-0
lines changed

5 files changed

+106
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<artifactId>spring-cloud-stream-kinesis</artifactId>
7+
<name>spring-cloud-stream-kinesis</name>
8+
9+
<parent>
10+
<groupId>org.springframework.boot</groupId>
11+
<artifactId>spring-boot-starter-parent</artifactId>
12+
<version>2.1.8.RELEASE</version>
13+
<relativePath/>
14+
</parent>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-starter-web</artifactId>
20+
</dependency>
21+
22+
<dependency>
23+
<groupId>org.springframework.cloud</groupId>
24+
<artifactId>spring-cloud-stream-binder-kinesis</artifactId>
25+
<version>${spring-cloud-stream-kinesis-binder.version}</version>
26+
</dependency>
27+
28+
<dependency>
29+
<groupId>com.amazonaws</groupId>
30+
<artifactId>aws-java-sdk-kinesis</artifactId>
31+
<version>${aws-sdk.version}</version>
32+
</dependency>
33+
34+
<dependency>
35+
<groupId>org.springframework.cloud</groupId>
36+
<artifactId>spring-cloud-stream-test-support</artifactId>
37+
<version>${spring-cloud-stream-test.version}</version>
38+
<scope>test</scope>
39+
</dependency>
40+
</dependencies>
41+
42+
<properties>
43+
<aws-sdk.version>1.11.632</aws-sdk.version>
44+
<spring-cloud-stream-kinesis-binder.version>1.2.1.RELEASE</spring-cloud-stream-kinesis-binder.version>
45+
<spring-cloud-stream-test.version>2.2.1.RELEASE</spring-cloud-stream-test.version>
46+
</properties>
47+
48+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.baeldung;
2+
3+
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.boot.SpringApplication;
5+
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
import org.springframework.cloud.stream.annotation.EnableBinding;
7+
import org.springframework.cloud.stream.annotation.StreamListener;
8+
import org.springframework.cloud.stream.messaging.Processor;
9+
import org.springframework.messaging.support.MessageBuilder;
10+
11+
@SpringBootApplication
12+
@EnableBinding(Processor.class)
13+
public class KinesisApplication {
14+
15+
public static void main(String[] args) {
16+
SpringApplication.run(KinesisApplication.class, args);
17+
}
18+
19+
@Autowired
20+
private Processor processor;
21+
22+
@StreamListener(Processor.INPUT)
23+
public void consume(String val) {
24+
System.out.println(val);
25+
}
26+
27+
public void produce(String val) {
28+
processor.output().send(MessageBuilder.withPayload(val).build());
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cloud.aws.credentials.access-key=aws-key
2+
cloud.aws.credentials.secret-key=aws-secret
3+
cloud.aws.region.static=eu-central-1
4+
cloud.aws.stack.auto=false
5+
6+
spring.cloud.stream.bindings.output.destination=myStream
7+
spring.cloud.stream.bindings.output.content-type=text/plain
8+
9+
spring.cloud.stream.bindings.input.destination=myStream
10+
spring.cloud.stream.bindings.input.group=myStream-group
11+
spring.cloud.stream.bindings.input.content-type=text/plain
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.baeldung;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringRunner;
7+
8+
@RunWith(SpringRunner.class)
9+
@SpringBootTest(classes = KinesisApplication.class)
10+
public class KinesisApplicationIntegrationTest {
11+
@Test
12+
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
13+
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cloud.aws.region.static=eu-central-1
2+
cloud.aws.stack.auto=false

0 commit comments

Comments
 (0)