BAEL-3165 Integrate Kinesis with Spring Binder
This commit is contained in:
parent
7d65b1fb24
commit
42ef916c80
@ -0,0 +1,48 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>spring-cloud-stream-kinesis</artifactId>
|
||||||
|
<name>spring-cloud-stream-kinesis</name>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.1.8.RELEASE</version>
|
||||||
|
<relativePath/>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-stream-binder-kinesis</artifactId>
|
||||||
|
<version>${spring-cloud-stream-kinesis-binder.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.amazonaws</groupId>
|
||||||
|
<artifactId>aws-java-sdk-kinesis</artifactId>
|
||||||
|
<version>${aws-sdk.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-stream-test-support</artifactId>
|
||||||
|
<version>${spring-cloud-stream-test.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<aws-sdk.version>1.11.632</aws-sdk.version>
|
||||||
|
<spring-cloud-stream-kinesis-binder.version>1.2.1.RELEASE</spring-cloud-stream-kinesis-binder.version>
|
||||||
|
<spring-cloud-stream-test.version>2.2.1.RELEASE</spring-cloud-stream-test.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.baeldung;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||||
|
import org.springframework.cloud.stream.annotation.StreamListener;
|
||||||
|
import org.springframework.cloud.stream.messaging.Processor;
|
||||||
|
import org.springframework.messaging.support.MessageBuilder;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableBinding(Processor.class)
|
||||||
|
public class KinesisApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(KinesisApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Processor processor;
|
||||||
|
|
||||||
|
@StreamListener(Processor.INPUT)
|
||||||
|
public void consume(String val) {
|
||||||
|
System.out.println(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void produce(String val) {
|
||||||
|
processor.output().send(MessageBuilder.withPayload(val).build());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
cloud.aws.credentials.access-key=aws-key
|
||||||
|
cloud.aws.credentials.secret-key=aws-secret
|
||||||
|
cloud.aws.region.static=eu-central-1
|
||||||
|
cloud.aws.stack.auto=false
|
||||||
|
|
||||||
|
spring.cloud.stream.bindings.output.destination=myStream
|
||||||
|
spring.cloud.stream.bindings.output.content-type=text/plain
|
||||||
|
|
||||||
|
spring.cloud.stream.bindings.input.destination=myStream
|
||||||
|
spring.cloud.stream.bindings.input.group=myStream-group
|
||||||
|
spring.cloud.stream.bindings.input.content-type=text/plain
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.baeldung;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(classes = KinesisApplication.class)
|
||||||
|
public class KinesisApplicationIntegrationTest {
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
cloud.aws.region.static=eu-central-1
|
||||||
|
cloud.aws.stack.auto=false
|
Loading…
x
Reference in New Issue
Block a user