Update Kotlin e2e sample
This commit is contained in:
@@ -3,25 +3,38 @@
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>io.spring.cloud.stream.sample</groupId>
|
||||
<artifactId>spring-cloud-stream-samples-parent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>customer-service</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>customer-service</name>
|
||||
<description>Customer Service</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<kotlin.version>1.3.31</kotlin.version>
|
||||
<avro.version>1.8.2</avro.version>
|
||||
<confluent.version>5.2.1</confluent.version>
|
||||
<spring-cloud.version>Hoxton.BUILD-SNAPSHOT</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.confluent</groupId>
|
||||
@@ -94,6 +107,18 @@
|
||||
<artifactId>spring-cloud-stream-test-support</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -145,6 +170,25 @@
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/libs-snapshot-local</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/libs-milestone-local</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>confluent</id>
|
||||
<url>https://packages.confluent.io/maven/</url>
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kafka.e2e.customer.configuration
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.cloud.stream.schema.client.ConfluentSchemaRegistryClient
|
||||
import org.springframework.cloud.stream.schema.client.SchemaRegistryClient
|
||||
import org.springframework.context.annotation.Bean
|
||||
|
||||
/**
|
||||
* @author José A. Íñigo
|
||||
*/
|
||||
@Configuration
|
||||
class SchemaRegistryConfiguration {
|
||||
|
||||
@Bean
|
||||
fun schemaRegistryClient(@Value("\${spring.cloud.stream.schema-registry-client.endpoint}") endpoint: String): SchemaRegistryClient {
|
||||
val client = ConfluentSchemaRegistryClient()
|
||||
client.setEndpoint(endpoint)
|
||||
return client
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,8 @@ spring:
|
||||
name: customer-service
|
||||
cloud:
|
||||
stream:
|
||||
schema-registry-client:
|
||||
endpoint: http://localhost:8081
|
||||
# schema-registry-client:
|
||||
# endpoint: http://localhost:8081
|
||||
kafka:
|
||||
bindings:
|
||||
output:
|
||||
@@ -19,7 +19,7 @@ spring:
|
||||
strategy: io.confluent.kafka.serializers.subject.RecordNameStrategy
|
||||
schema:
|
||||
registry:
|
||||
url: ${spring.cloud.stream.schema-registry-client.endpoint}
|
||||
url: http://localhost:8081
|
||||
bindings:
|
||||
output:
|
||||
destination: customer
|
||||
|
||||
@@ -3,25 +3,38 @@
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>io.spring.cloud.stream.sample</groupId>
|
||||
<artifactId>spring-cloud-stream-samples-parent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>order-service</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>order-service</name>
|
||||
<description>Order Service</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<kotlin.version>1.3.31</kotlin.version>
|
||||
<avro.version>1.8.2</avro.version>
|
||||
<confluent.version>5.2.1</confluent.version>
|
||||
<spring-cloud.version>Hoxton.BUILD-SNAPSHOT</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.confluent</groupId>
|
||||
@@ -145,6 +158,25 @@
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/libs-snapshot-local</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/libs-milestone-local</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>confluent</id>
|
||||
<url>https://packages.confluent.io/maven/</url>
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kafka.e2e.order.configuration
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.cloud.stream.schema.client.ConfluentSchemaRegistryClient
|
||||
import org.springframework.cloud.stream.schema.client.SchemaRegistryClient
|
||||
import org.springframework.context.annotation.Bean
|
||||
|
||||
/**
|
||||
* @author José A. Íñigo
|
||||
*/
|
||||
@Configuration
|
||||
class SchemaRegistryConfiguration {
|
||||
|
||||
@Bean
|
||||
fun schemaRegistryClient(@Value("\${spring.cloud.stream.schema-registry-client.endpoint}") endpoint: String): SchemaRegistryClient {
|
||||
val client = ConfluentSchemaRegistryClient()
|
||||
client.setEndpoint(endpoint)
|
||||
return client
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,8 @@ spring:
|
||||
name: order-service
|
||||
cloud:
|
||||
stream:
|
||||
schema-registry-client:
|
||||
endpoint: http://localhost:8081
|
||||
# schema-registry-client:
|
||||
# endpoint: http://localhost:8081
|
||||
kafka:
|
||||
bindings:
|
||||
output:
|
||||
@@ -19,7 +19,7 @@ spring:
|
||||
strategy: io.confluent.kafka.serializers.subject.RecordNameStrategy
|
||||
schema:
|
||||
registry:
|
||||
url: ${spring.cloud.stream.schema-registry-client.endpoint}
|
||||
url: http://localhost:8081
|
||||
bindings:
|
||||
output:
|
||||
destination: order
|
||||
|
||||
@@ -3,25 +3,38 @@
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>io.spring.cloud.stream.sample</groupId>
|
||||
<artifactId>spring-cloud-stream-samples-parent</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>shipping-service</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>shipping-service</name>
|
||||
<description>Shipping Service</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<kotlin.version>1.3.31</kotlin.version>
|
||||
<avro.version>1.8.2</avro.version>
|
||||
<confluent.version>5.2.1</confluent.version>
|
||||
<spring-cloud.version>Hoxton.BUILD-SNAPSHOT</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.confluent</groupId>
|
||||
@@ -94,6 +107,18 @@
|
||||
<artifactId>spring-cloud-stream-test-support</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -145,6 +170,25 @@
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/libs-snapshot-local</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/libs-milestone-local</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>confluent</id>
|
||||
<url>https://packages.confluent.io/maven/</url>
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kafka.e2e.shipping.configuration
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.cloud.stream.schema.avro.AvroSchemaMessageConverter
|
||||
import org.springframework.cloud.stream.schema.client.ConfluentSchemaRegistryClient
|
||||
import org.springframework.cloud.stream.schema.client.SchemaRegistryClient
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.messaging.converter.MessageConverter
|
||||
import org.springframework.util.MimeType
|
||||
|
||||
/**
|
||||
* @author José A. Íñigo
|
||||
*/
|
||||
@Configuration
|
||||
class SchemaRegistryConfiguration {
|
||||
|
||||
@Bean
|
||||
fun schemaRegistryClient(@Value("\${spring.cloud.stream.schema-registry-client.endpoint}") endpoint: String): SchemaRegistryClient {
|
||||
val client = ConfluentSchemaRegistryClient()
|
||||
client.setEndpoint(endpoint)
|
||||
return client
|
||||
}
|
||||
|
||||
@Bean
|
||||
fun messageConverter(): MessageConverter {
|
||||
return AvroSchemaMessageConverter(MimeType.valueOf("avro/bytes"))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,10 +56,8 @@ class ShippingKStreamConfiguration {
|
||||
|
||||
val stateStore: Materialized<Int, Customer, KeyValueStore<Bytes, ByteArray>> =
|
||||
Materialized.`as`<Int, Customer, KeyValueStore<Bytes, ByteArray>>("customer-store")
|
||||
.withKeySerde(intSerde)
|
||||
.withValueSerde(customerSerde)
|
||||
|
||||
val customerTable: KTable<Int, Customer> = input.groupByKey(Serialized.with(intSerde, customerSerde))
|
||||
val customerTable: KTable<Int, Customer> = input.groupByKey()
|
||||
.reduce({ _, y -> y }, stateStore)
|
||||
|
||||
return (orderEvent.filter { _, value -> value.schema.name == "OrderCreatedEvent" }
|
||||
|
||||
@@ -3,20 +3,15 @@ spring:
|
||||
name: shipping-service
|
||||
cloud:
|
||||
stream:
|
||||
schema-registry-client:
|
||||
endpoint: http://localhost:8081
|
||||
kafka:
|
||||
streams:
|
||||
binder:
|
||||
configuration:
|
||||
application:
|
||||
id: shipping-service
|
||||
default:
|
||||
key:
|
||||
serde: org.apache.kafka.common.serialization.Serdes$IntegerSerde
|
||||
schema:
|
||||
registry:
|
||||
url: ${spring.cloud.stream.schema-registry-client.endpoint}
|
||||
url: http://localhost:8081
|
||||
value:
|
||||
subject:
|
||||
name:
|
||||
|
||||
Reference in New Issue
Block a user