diff --git a/batch-producer-consumer/pom.xml b/batch-producer-consumer/pom.xml index 06517775..c945c9c2 100644 --- a/batch-producer-consumer/pom.xml +++ b/batch-producer-consumer/pom.xml @@ -16,7 +16,6 @@ Sample app using stream functions with batch producer and consumer using kafka 17 - 2023.0.0-SNAPSHOT @@ -48,18 +47,6 @@ test - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - @@ -79,69 +66,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - confluent - https://packages.confluent.io/maven/ - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - - diff --git a/confluent-schema-registry-integration/pom.xml b/confluent-schema-registry-integration/pom.xml index 02148987..dcbc120f 100644 --- a/confluent-schema-registry-integration/pom.xml +++ b/confluent-schema-registry-integration/pom.xml @@ -55,7 +55,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc org.springframework.cloud @@ -88,68 +88,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - confluent - https://packages.confluent.io/maven/ - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/function-based-stream-app-samples/couchbase-stream-applications/couchbase-consumer/pom.xml b/function-based-stream-app-samples/couchbase-stream-applications/couchbase-consumer/pom.xml index 4a60fd53..e8287bd9 100644 --- a/function-based-stream-app-samples/couchbase-stream-applications/couchbase-consumer/pom.xml +++ b/function-based-stream-app-samples/couchbase-stream-applications/couchbase-consumer/pom.xml @@ -42,14 +42,27 @@ org.testcontainers - couchbase + testcontainers-couchbase test org.testcontainers - junit-jupiter + testcontainers-junit-jupiter test + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + diff --git a/function-based-stream-app-samples/couchbase-stream-applications/couchbase-consumer/src/main/java/io/spring/example/couchbase/consumer/CouchbaseConsumerProperties.java b/function-based-stream-app-samples/couchbase-stream-applications/couchbase-consumer/src/main/java/io/spring/example/couchbase/consumer/CouchbaseConsumerProperties.java index 8bae6e9b..b14b4d8e 100644 --- a/function-based-stream-app-samples/couchbase-stream-applications/couchbase-consumer/src/main/java/io/spring/example/couchbase/consumer/CouchbaseConsumerProperties.java +++ b/function-based-stream-app-samples/couchbase-stream-applications/couchbase-consumer/src/main/java/io/spring/example/couchbase/consumer/CouchbaseConsumerProperties.java @@ -16,7 +16,7 @@ package io.spring.example.couchbase.consumer; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.expression.Expression; diff --git a/function-based-stream-app-samples/couchbase-stream-applications/couchbase-consumer/src/test/java/io/spring/example/couchbase/consumer/CouchbaseConsumerTests.java b/function-based-stream-app-samples/couchbase-stream-applications/couchbase-consumer/src/test/java/io/spring/example/couchbase/consumer/CouchbaseConsumerTests.java index 18fb618b..ac3790c9 100644 --- a/function-based-stream-app-samples/couchbase-stream-applications/couchbase-consumer/src/test/java/io/spring/example/couchbase/consumer/CouchbaseConsumerTests.java +++ b/function-based-stream-app-samples/couchbase-stream-applications/couchbase-consumer/src/test/java/io/spring/example/couchbase/consumer/CouchbaseConsumerTests.java @@ -21,7 +21,7 @@ import java.util.function.Consumer; import java.util.function.Function; -import javax.annotation.PreDestroy; +import jakarta.annotation.PreDestroy; import com.couchbase.client.java.Bucket; import com.couchbase.client.java.Cluster; diff --git a/function-based-stream-app-samples/couchbase-stream-applications/couchbase-sink/README.adoc b/function-based-stream-app-samples/couchbase-stream-applications/couchbase-sink/README.adoc index 8ab130fe..5c3cb03c 100644 --- a/function-based-stream-app-samples/couchbase-stream-applications/couchbase-sink/README.adoc +++ b/function-based-stream-app-samples/couchbase-stream-applications/couchbase-sink/README.adoc @@ -4,19 +4,4 @@ The **$$couchbase$$** $$sink$$ has the following options: //tag::configuration-properties[] -Properties grouped by prefix: - - -=== couchbase.consumer - -$$bucket-expression$$:: $$A SpEL expression to specify the bucket.$$ *($$Expression$$, default: `$$$$`)* -$$collection-expression$$:: $$A SpEL expression to specify the collection.$$ *($$Expression$$, default: `$$$$`)* -$$key-expression$$:: $$A SpEL expression to specify the key.$$ *($$Expression$$, default: `$$$$`)* -$$value-expression$$:: $$A SpEL expression to specify the value (default is payload).$$ *($$Expression$$, default: `$$$$`)* - -=== spring.couchbase - -$$connection-string$$:: $$Connection string used to locate the Couchbase cluster.$$ *($$String$$, default: `$$$$`)* -$$password$$:: $$Cluster password.$$ *($$String$$, default: `$$$$`)* -$$username$$:: $$Cluster username.$$ *($$String$$, default: `$$$$`)* //end::configuration-properties[] diff --git a/function-based-stream-app-samples/couchbase-stream-applications/couchbase-sink/pom.xml b/function-based-stream-app-samples/couchbase-stream-applications/couchbase-sink/pom.xml index b8f09b4d..b3629aec 100644 --- a/function-based-stream-app-samples/couchbase-stream-applications/couchbase-sink/pom.xml +++ b/function-based-stream-app-samples/couchbase-stream-applications/couchbase-sink/pom.xml @@ -39,24 +39,22 @@ org.springframework.cloud - spring-cloud-stream - test-jar - test-binder + spring-cloud-stream-test-binder test org.testcontainers - couchbase + testcontainers-couchbase test org.testcontainers - kafka + testcontainers-kafka test org.testcontainers - junit-jupiter + testcontainers-junit-jupiter test diff --git a/function-based-stream-app-samples/couchbase-stream-applications/pom.xml b/function-based-stream-app-samples/couchbase-stream-applications/pom.xml index 618ed324..299fce7a 100644 --- a/function-based-stream-app-samples/couchbase-stream-applications/pom.xml +++ b/function-based-stream-app-samples/couchbase-stream-applications/pom.xml @@ -3,10 +3,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + function-based-stream-app-samples + 0.0.1-SNAPSHOT + .. io.spring.example couchbase-stream-applications @@ -16,11 +16,7 @@ Demo Stream Applications project for Couchhbase - 8 - 2020.0.2 - 1.86 - 3.0.10 - 1.15.1 + 3.7.5 @@ -36,48 +32,9 @@ java-client ${couchbase-java-client.version} - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - org.testcontainers - testcontainers-bom - ${test-containers.version} - pom - import - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - diff --git a/function-based-stream-app-samples/image-thumbnail-samples/image-thumbnail-processor/pom.xml b/function-based-stream-app-samples/image-thumbnail-samples/image-thumbnail-processor/pom.xml index 25d70301..e4ae7d62 100644 --- a/function-based-stream-app-samples/image-thumbnail-samples/image-thumbnail-processor/pom.xml +++ b/function-based-stream-app-samples/image-thumbnail-samples/image-thumbnail-processor/pom.xml @@ -3,10 +3,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + image-thumbnail-samples + 0.0.1-SNAPSHOT + .. io.spring.cloud.stream.sample image-thumbnail-processor @@ -14,10 +14,6 @@ image-thumbnail-processor Thumbnail processor - - 8 - - org.junit.jupiter @@ -38,4 +34,17 @@ + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + diff --git a/function-based-stream-app-samples/image-thumbnail-samples/image-thumbnail-stream-sample/image-thumbnail-sink/pom.xml b/function-based-stream-app-samples/image-thumbnail-samples/image-thumbnail-stream-sample/image-thumbnail-sink/pom.xml index 5519d430..6d18670e 100644 --- a/function-based-stream-app-samples/image-thumbnail-samples/image-thumbnail-stream-sample/image-thumbnail-sink/pom.xml +++ b/function-based-stream-app-samples/image-thumbnail-samples/image-thumbnail-stream-sample/image-thumbnail-sink/pom.xml @@ -3,10 +3,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + image-thumbnail-samples + 0.0.1-SNAPSHOT + ../.. io.spring.cloud.stream.sample image-thumbnail-sink @@ -14,8 +14,6 @@ image-thumbnail-sink Thumbnail Sink Application - 8 - 2020.0.2 demo @@ -46,12 +44,6 @@ org.springframework.boot spring-boot-starter-test test - - - org.junit.vintage - junit-vintage-engine - - org.awaitility @@ -60,9 +52,7 @@ org.springframework.cloud - spring-cloud-stream - test-jar - test-binder + spring-cloud-stream-test-binder test @@ -70,17 +60,6 @@ reactor-test - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - @@ -109,46 +88,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestonl - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - + \ No newline at end of file diff --git a/function-based-stream-app-samples/image-thumbnail-samples/image-thumbnail-web/pom.xml b/function-based-stream-app-samples/image-thumbnail-samples/image-thumbnail-web/pom.xml index a94d7e6b..9f54b59f 100644 --- a/function-based-stream-app-samples/image-thumbnail-samples/image-thumbnail-web/pom.xml +++ b/function-based-stream-app-samples/image-thumbnail-samples/image-thumbnail-web/pom.xml @@ -3,10 +3,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + image-thumbnail-samples + 0.0.1-SNAPSHOT + .. io.spring.cloud.stream.sample image-thumbnail-web @@ -14,10 +14,6 @@ image-thumbnail-web Demo project for Spring Boot - - 8 - - org.springframework.cloud.fn @@ -44,12 +40,6 @@ org.springframework.boot spring-boot-starter-test test - - - org.junit.vintage - junit-vintage-engine - - @@ -62,47 +52,4 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - diff --git a/function-based-stream-app-samples/image-thumbnail-samples/pom.xml b/function-based-stream-app-samples/image-thumbnail-samples/pom.xml index a08cd26c..f6d58a03 100644 --- a/function-based-stream-app-samples/image-thumbnail-samples/pom.xml +++ b/function-based-stream-app-samples/image-thumbnail-samples/pom.xml @@ -2,6 +2,12 @@ 4.0.0 + + io.spring.cloud.stream.sample + function-based-stream-app-samples + 0.0.1-SNAPSHOT + .. + io.spring.cloud.stream.sample image-thumbnail-samples 0.0.1-SNAPSHOT @@ -9,10 +15,6 @@ Samples using HTTP Request Function pom - - 8 - - image-thumbnail-web image-thumbnail-stream-sample/image-thumbnail-sink diff --git a/function-based-stream-app-samples/pom.xml b/function-based-stream-app-samples/pom.xml index e04fe1da..6829b9d3 100644 --- a/function-based-stream-app-samples/pom.xml +++ b/function-based-stream-app-samples/pom.xml @@ -2,6 +2,12 @@ 4.0.0 + + io.spring.cloud.stream.sample + spring-cloud-stream-samples-parent + 0.0.1-SNAPSHOT + .. + io.spring.cloud.stream.sample function-based-stream-app-samples 0.0.1-SNAPSHOT @@ -9,10 +15,6 @@ Samples using Functions and Function-based stream applications pom - - 8 - - image-thumbnail-samples couchbase-stream-applications diff --git a/kafka-batch-sample/pom.xml b/kafka-batch-sample/pom.xml index 3e193f0e..6d3de590 100644 --- a/kafka-batch-sample/pom.xml +++ b/kafka-batch-sample/pom.xml @@ -3,10 +3,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.3.3.RELEASE - + io.spring.cloud.stream.sample + spring-cloud-stream-samples-parent + 0.0.1-SNAPSHOT + .. com.example kafka-batch-sample @@ -14,10 +14,6 @@ kafka-batch-sample Demo project for Spring Boot - - 1.8 - Hoxton.SR8 - @@ -37,16 +33,10 @@ org.springframework.boot spring-boot-starter-test test - - - org.junit.vintage - junit-vintage-engine - - org.springframework.cloud - spring-cloud-stream-test-support + spring-cloud-stream-test-binder test @@ -56,18 +46,6 @@ - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - diff --git a/kafka-batch-sample/src/main/resources/application.yml b/kafka-batch-sample/src/main/resources/application.yml index 8696e7bc..3d6f4c26 100644 --- a/kafka-batch-sample/src/main/resources/application.yml +++ b/kafka-batch-sample/src/main/resources/application.yml @@ -17,7 +17,9 @@ spring: --- spring: - profiles: transactional + config: + activate: + on-profile: transactional kafka: consumer: properties: @@ -32,7 +34,9 @@ spring: --- spring: - profiles: batch-produce + config: + activate: + on-profile: batch-produce cloud: stream: bindings: diff --git a/kafka-batch-sample/src/test/java/com/example/demo/KafkaBatchSampleApplicationTests.java b/kafka-batch-sample/src/test/java/com/example/demo/KafkaBatchSampleApplicationTests.java index 38e0aed1..44f31bfe 100644 --- a/kafka-batch-sample/src/test/java/com/example/demo/KafkaBatchSampleApplicationTests.java +++ b/kafka-batch-sample/src/test/java/com/example/demo/KafkaBatchSampleApplicationTests.java @@ -2,8 +2,10 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.kafka.test.context.EmbeddedKafka; @SpringBootTest +@EmbeddedKafka(topics = {"batch-in", "batch-out"}, bootstrapServersProperty = "spring.kafka.bootstrap-servers") class KafkaBatchSampleApplicationTests { @Test diff --git a/kafka-binder-native-app/pom.xml b/kafka-binder-native-app/pom.xml index 4d1ab0ed..c47f23a1 100644 --- a/kafka-binder-native-app/pom.xml +++ b/kafka-binder-native-app/pom.xml @@ -71,69 +71,4 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - confluent - https://packages.confluent.io/maven/ - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - - - diff --git a/kafka-e2e-kotlin-sample/customer-service/pom.xml b/kafka-e2e-kotlin-sample/customer-service/pom.xml index 642b83cc..ba24a731 100644 --- a/kafka-e2e-kotlin-sample/customer-service/pom.xml +++ b/kafka-e2e-kotlin-sample/customer-service/pom.xml @@ -9,32 +9,17 @@ Customer Service - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-e2e-kotlin-sample + 0.0.1-SNAPSHOT + .. - 1.8 - 1.3.31 1.11.3 5.2.1 - 2020.0.2 - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - io.confluent @@ -64,19 +49,18 @@ org.springframework.cloud - spring-cloud-starter-stream-kafka + spring-cloud-stream-binder-kafka org.springframework.cloud - spring-cloud-stream-schema - 3.0.0.BUILD-SNAPSHOT + spring-cloud-stream-schema-registry-client org.springframework.boot spring-boot-starter-webflux - com.fasterxml.jackson.module + tools.jackson.module jackson-module-kotlin @@ -85,7 +69,7 @@ org.jetbrains.kotlin - kotlin-stdlib-jdk8 + kotlin-stdlib org.springframework.cloud @@ -104,7 +88,7 @@ org.springframework.cloud - spring-cloud-stream-test-support + spring-cloud-stream-test-binder test @@ -117,7 +101,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -169,30 +153,4 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - confluent - https://packages.confluent.io/maven/ - - - diff --git a/kafka-e2e-kotlin-sample/customer-service/src/main/kotlin/kafka/e2e/customer/CustomerServiceApplication.kt b/kafka-e2e-kotlin-sample/customer-service/src/main/kotlin/kafka/e2e/customer/CustomerServiceApplication.kt index 02096656..f0bfdd03 100644 --- a/kafka-e2e-kotlin-sample/customer-service/src/main/kotlin/kafka/e2e/customer/CustomerServiceApplication.kt +++ b/kafka-e2e-kotlin-sample/customer-service/src/main/kotlin/kafka/e2e/customer/CustomerServiceApplication.kt @@ -18,13 +18,10 @@ package kafka.e2e.customer import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication -import org.springframework.cloud.stream.annotation.EnableBinding -import org.springframework.cloud.stream.messaging.Source /** - * @author José A. Íñigo + * @author Jose A. Inigo */ -@EnableBinding(Source::class) @SpringBootApplication class CustomerServiceApplication diff --git a/kafka-e2e-kotlin-sample/customer-service/src/main/kotlin/kafka/e2e/customer/service/CustomerServiceImpl.kt b/kafka-e2e-kotlin-sample/customer-service/src/main/kotlin/kafka/e2e/customer/service/CustomerServiceImpl.kt index 3f244f95..5f86471f 100644 --- a/kafka-e2e-kotlin-sample/customer-service/src/main/kotlin/kafka/e2e/customer/service/CustomerServiceImpl.kt +++ b/kafka-e2e-kotlin-sample/customer-service/src/main/kotlin/kafka/e2e/customer/service/CustomerServiceImpl.kt @@ -17,19 +17,19 @@ package kafka.e2e.customer.service import kafka.e2e.customer.Customer -import org.springframework.cloud.stream.messaging.Source +import org.springframework.cloud.stream.function.StreamBridge import org.springframework.kafka.support.KafkaHeaders import org.springframework.messaging.support.MessageBuilder import org.springframework.stereotype.Service /** - * @author José A. Íñigo + * @author Jose A. Inigo */ @Service -class CustomerServiceImpl(private val customerKafkaProducer: Source) : CustomerService { +class CustomerServiceImpl(private val streamBridge: StreamBridge) : CustomerService { override fun save(customer: Customer) { - val message = MessageBuilder.withPayload(customer).setHeader(KafkaHeaders.MESSAGE_KEY, customer.getId()).build() - customerKafkaProducer.output().send(message) + val message = MessageBuilder.withPayload(customer).setHeader(KafkaHeaders.KEY, customer.getId()).build() + streamBridge.send("output", message) } } diff --git a/kafka-e2e-kotlin-sample/order-service/pom.xml b/kafka-e2e-kotlin-sample/order-service/pom.xml index 36e0858c..9b56f12e 100644 --- a/kafka-e2e-kotlin-sample/order-service/pom.xml +++ b/kafka-e2e-kotlin-sample/order-service/pom.xml @@ -9,32 +9,17 @@ Order Service - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-e2e-kotlin-sample + 0.0.1-SNAPSHOT + .. - 1.8 - 1.3.31 1.11.3 5.2.1 - 2020.0.2 - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - io.confluent @@ -64,19 +49,18 @@ org.springframework.cloud - spring-cloud-starter-stream-kafka + spring-cloud-stream-binder-kafka org.springframework.cloud - spring-cloud-stream-schema - 3.0.0.BUILD-SNAPSHOT + spring-cloud-stream-schema-registry-client org.springframework.boot spring-boot-starter-webflux - com.fasterxml.jackson.module + tools.jackson.module jackson-module-kotlin @@ -85,7 +69,7 @@ org.jetbrains.kotlin - kotlin-stdlib-jdk8 + kotlin-stdlib org.springframework.cloud @@ -104,7 +88,7 @@ org.springframework.cloud - spring-cloud-stream-test-support + spring-cloud-stream-test-binder test @@ -157,30 +141,4 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - confluent - https://packages.confluent.io/maven/ - - - diff --git a/kafka-e2e-kotlin-sample/order-service/src/main/kotlin/kafka/e2e/order/OrderServiceApplication.kt b/kafka-e2e-kotlin-sample/order-service/src/main/kotlin/kafka/e2e/order/OrderServiceApplication.kt index ec304559..2764ec0d 100644 --- a/kafka-e2e-kotlin-sample/order-service/src/main/kotlin/kafka/e2e/order/OrderServiceApplication.kt +++ b/kafka-e2e-kotlin-sample/order-service/src/main/kotlin/kafka/e2e/order/OrderServiceApplication.kt @@ -18,15 +18,10 @@ package kafka.e2e.order import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication -import org.springframework.cloud.stream.annotation.EnableBinding -import org.springframework.cloud.stream.messaging.Source -import org.springframework.cloud.stream.schema.client.EnableSchemaRegistryClient /** - * @author José A. Íñigo + * @author Jose A. Inigo */ -@EnableSchemaRegistryClient -@EnableBinding(Source::class) @SpringBootApplication class OrderServiceApplication diff --git a/kafka-e2e-kotlin-sample/order-service/src/main/kotlin/kafka/e2e/order/producer/OrderProducer.kt b/kafka-e2e-kotlin-sample/order-service/src/main/kotlin/kafka/e2e/order/producer/OrderProducer.kt index d61515ed..ddfbcfef 100644 --- a/kafka-e2e-kotlin-sample/order-service/src/main/kotlin/kafka/e2e/order/producer/OrderProducer.kt +++ b/kafka-e2e-kotlin-sample/order-service/src/main/kotlin/kafka/e2e/order/producer/OrderProducer.kt @@ -18,20 +18,21 @@ package kafka.e2e.order.producer import kafka.e2e.order.OrderCreatedEvent import kafka.e2e.order.dto.Order -import org.springframework.cloud.stream.messaging.Source +import org.springframework.cloud.stream.function.StreamBridge import org.springframework.kafka.support.KafkaHeaders import org.springframework.messaging.support.MessageBuilder import org.springframework.stereotype.Component /** - * @author José A. Íñigo + * @author Jose A. Inigo */ @Component -class OrderProducer(private val source: Source) { +class OrderProducer(private val streamBridge: StreamBridge) { fun publishOrderCreatedEvent(order: Order) { - source.output().send(MessageBuilder.withPayload(OrderCreatedEvent(order.id, order.productId, order.customerId)) - .setHeader(KafkaHeaders.MESSAGE_KEY, order.id).build()) + val message = MessageBuilder.withPayload(OrderCreatedEvent(order.id, order.productId, order.customerId)) + .setHeader(KafkaHeaders.KEY, order.id).build() + streamBridge.send("output", message) } } diff --git a/kafka-e2e-kotlin-sample/pom.xml b/kafka-e2e-kotlin-sample/pom.xml index 0036d4c5..763c84b9 100644 --- a/kafka-e2e-kotlin-sample/pom.xml +++ b/kafka-e2e-kotlin-sample/pom.xml @@ -1,6 +1,12 @@ 4.0.0 + + io.spring.cloud.stream.sample + spring-cloud-stream-samples-parent + 0.0.1-SNAPSHOT + .. + io.spring.cloud.stream.sample kafka-e2e-kotlin-sample 0.0.1-SNAPSHOT diff --git a/kafka-e2e-kotlin-sample/shipping-service/pom.xml b/kafka-e2e-kotlin-sample/shipping-service/pom.xml index 8beacb2f..719ac8d4 100644 --- a/kafka-e2e-kotlin-sample/shipping-service/pom.xml +++ b/kafka-e2e-kotlin-sample/shipping-service/pom.xml @@ -9,32 +9,17 @@ Shipping Service - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-e2e-kotlin-sample + 0.0.1-SNAPSHOT + .. - 1.8 - 1.3.31 1.11.3 5.2.1 - 2020.0.2 - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - io.confluent @@ -68,15 +53,14 @@ org.springframework.cloud - spring-cloud-stream-schema - 3.0.0.BUILD-SNAPSHOT + spring-cloud-stream-schema-registry-client org.springframework.boot spring-boot-starter-webflux - com.fasterxml.jackson.module + tools.jackson.module jackson-module-kotlin @@ -85,7 +69,7 @@ org.jetbrains.kotlin - kotlin-stdlib-jdk8 + kotlin-stdlib org.springframework.cloud @@ -104,7 +88,7 @@ org.springframework.cloud - spring-cloud-stream-test-support + spring-cloud-stream-test-binder test @@ -117,7 +101,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -169,30 +153,4 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - confluent - https://packages.confluent.io/maven/ - - - diff --git a/kafka-e2e-kotlin-sample/shipping-service/src/main/kotlin/kafka/e2e/shipping/ShippingServiceApplication.kt b/kafka-e2e-kotlin-sample/shipping-service/src/main/kotlin/kafka/e2e/shipping/ShippingServiceApplication.kt index ae6c2ddb..9d74e1ab 100644 --- a/kafka-e2e-kotlin-sample/shipping-service/src/main/kotlin/kafka/e2e/shipping/ShippingServiceApplication.kt +++ b/kafka-e2e-kotlin-sample/shipping-service/src/main/kotlin/kafka/e2e/shipping/ShippingServiceApplication.kt @@ -16,15 +16,12 @@ package kafka.e2e.shipping -import kafka.e2e.shipping.stream.ShippingKStreamProcessor import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication -import org.springframework.cloud.stream.annotation.EnableBinding /** - * @author José A. Íñigo + * @author Jose A. Inigo */ -@EnableBinding(ShippingKStreamProcessor::class) @SpringBootApplication class ShippingServiceApplication diff --git a/kafka-e2e-kotlin-sample/shipping-service/src/main/kotlin/kafka/e2e/shipping/stream/ShippingKStreamConfiguration.kt b/kafka-e2e-kotlin-sample/shipping-service/src/main/kotlin/kafka/e2e/shipping/stream/ShippingKStreamConfiguration.kt index a06773a0..0d8c4b8e 100644 --- a/kafka-e2e-kotlin-sample/shipping-service/src/main/kotlin/kafka/e2e/shipping/stream/ShippingKStreamConfiguration.kt +++ b/kafka-e2e-kotlin-sample/shipping-service/src/main/kotlin/kafka/e2e/shipping/stream/ShippingKStreamConfiguration.kt @@ -27,46 +27,46 @@ import org.apache.kafka.common.utils.Bytes import org.apache.kafka.streams.KeyValue import org.apache.kafka.streams.kstream.* import org.apache.kafka.streams.state.KeyValueStore -import org.springframework.cloud.stream.annotation.Input -import org.springframework.cloud.stream.annotation.StreamListener +import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration -import org.springframework.messaging.handler.annotation.SendTo +import java.util.function.BiFunction /** - * @author José A. Íñigo + * @author Jose A. Inigo */ @Suppress("UNCHECKED_CAST") @Configuration class ShippingKStreamConfiguration { - @StreamListener - @SendTo("output") - fun process(@Input("input") input: KStream, @Input("order") orderEvent: KStream): KStream { + @Bean + fun process(): BiFunction, KStream, KStream> { + return BiFunction { input, orderEvent -> - val serdeConfig = mapOf( - AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG to "http://localhost:8081") + val serdeConfig = mapOf( + AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG to "http://localhost:8081") - val intSerde = Serdes.IntegerSerde() - val customerSerde = SpecificAvroSerde() - customerSerde.configure(serdeConfig, false) - val orderCreatedSerde = SpecificAvroSerde() - orderCreatedSerde.configure(serdeConfig, false) - val orderShippedSerde = SpecificAvroSerde() - orderShippedSerde.configure(serdeConfig, false) + val intSerde = Serdes.IntegerSerde() + val customerSerde = SpecificAvroSerde() + customerSerde.configure(serdeConfig, false) + val orderCreatedSerde = SpecificAvroSerde() + orderCreatedSerde.configure(serdeConfig, false) + val orderShippedSerde = SpecificAvroSerde() + orderShippedSerde.configure(serdeConfig, false) - val stateStore: Materialized> = - Materialized.`as`>("customer-store") + val stateStore: Materialized> = + Materialized.`as`>("customer-store") - val customerTable: KTable = input.groupByKey() - .reduce({ _, y -> y }, stateStore) + val customerTable: KTable = input.groupByKey() + .reduce({ _, y -> y }, stateStore) - return (orderEvent.filter { _, value -> value.schema.name == "OrderCreatedEvent" } - .map { key, value -> KeyValue(key, OrderCreatedEvent(value.get("id") as Int, value.get("productId") as Int, value.get("customerId") as Int)) } - .selectKey { _, value -> value.customerId } as KStream) - .join(customerTable, { orderIt, customer -> - OrderShippedEvent(orderIt.id, orderIt.productId, customer.name, customer.address) - }, Joined.with(intSerde, orderCreatedSerde, customerSerde)) - .selectKey { _, value -> value.id } + (orderEvent.filter { _, value -> value.schema.name == "OrderCreatedEvent" } + .map { key, value -> KeyValue(key, OrderCreatedEvent(value.get("id") as Int, value.get("productId") as Int, value.get("customerId") as Int)) } + .selectKey { _, value -> value.customerId } as KStream) + .join(customerTable, { orderIt, customer -> + OrderShippedEvent(orderIt.id, orderIt.productId, customer.name, customer.address) + }, Joined.with(intSerde, orderCreatedSerde, customerSerde)) + .selectKey { _, value -> value.id } + } } } diff --git a/kafka-e2e-kotlin-sample/shipping-service/src/main/kotlin/kafka/e2e/shipping/stream/ShippingKStreamProcessor.kt b/kafka-e2e-kotlin-sample/shipping-service/src/main/kotlin/kafka/e2e/shipping/stream/ShippingKStreamProcessor.kt deleted file mode 100644 index 0c8d2edc..00000000 --- a/kafka-e2e-kotlin-sample/shipping-service/src/main/kotlin/kafka/e2e/shipping/stream/ShippingKStreamProcessor.kt +++ /dev/null @@ -1,40 +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.stream - -import kafka.e2e.customer.Customer -import kafka.e2e.order.OrderCreatedEvent -import kafka.e2e.shipping.OrderShippedEvent -import org.apache.kafka.streams.kstream.KStream -import org.springframework.cloud.stream.annotation.Input -import org.springframework.cloud.stream.annotation.Output - -/** - * @author José A. Íñigo - */ -interface ShippingKStreamProcessor { - - @Input("input") - fun input(): KStream - - @Input("order") - fun order(): KStream - - @Output("output") - fun output(): KStream - -} diff --git a/kafka-e2e-kotlin-sample/shipping-service/src/main/resources/application.yml b/kafka-e2e-kotlin-sample/shipping-service/src/main/resources/application.yml index 4d4e68b3..5eb1e36f 100644 --- a/kafka-e2e-kotlin-sample/shipping-service/src/main/resources/application.yml +++ b/kafka-e2e-kotlin-sample/shipping-service/src/main/resources/application.yml @@ -3,6 +3,8 @@ spring: name: shipping-service cloud: stream: + function: + definition: process kafka: streams: binder: @@ -17,21 +19,21 @@ spring: name: strategy: io.confluent.kafka.serializers.subject.RecordNameStrategy bindings: - input: + process-in-0: consumer: valueSerde: io.confluent.kafka.streams.serdes.avro.SpecificAvroSerde - order: + process-in-1: consumer: valueSerde: io.confluent.kafka.streams.serdes.avro.GenericAvroSerde - output: + process-out-0: producer: valueSerde: io.confluent.kafka.streams.serdes.avro.SpecificAvroSerde bindings: - input: + process-in-0: destination: customer - order: + process-in-1: destination: order - output: + process-out-0: destination: order server: diff --git a/kafka-native-serialization/pom.xml b/kafka-native-serialization/pom.xml index 659fd5a5..a98124dc 100644 --- a/kafka-native-serialization/pom.xml +++ b/kafka-native-serialization/pom.xml @@ -3,10 +3,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + spring-cloud-stream-samples-parent + 0.0.1-SNAPSHOT + .. com.example kafka-native-serialization @@ -14,10 +14,6 @@ kafka-native-serialization Demo project for Spring Boot - - 1.8 - 3.1.2 - @@ -26,7 +22,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc org.springframework.cloud @@ -51,25 +47,8 @@ spring-kafka-test test - - org.junit.vintage - junit-vintage-engine - test - - - - - org.springframework.cloud - spring-cloud-stream-dependencies - ${spring-cloud-stream.version} - pom - import - - - - @@ -79,55 +58,4 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - - diff --git a/kafka-native-serialization/src/test/java/com/example/kafkanativeserialization/KafkaNativeSerializationApplicationTests.java b/kafka-native-serialization/src/test/java/com/example/kafkanativeserialization/KafkaNativeSerializationApplicationTests.java index 0212eca0..40965bd0 100644 --- a/kafka-native-serialization/src/test/java/com/example/kafkanativeserialization/KafkaNativeSerializationApplicationTests.java +++ b/kafka-native-serialization/src/test/java/com/example/kafkanativeserialization/KafkaNativeSerializationApplicationTests.java @@ -24,46 +24,41 @@ import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.consumer.ConsumerRecords; import org.apache.kafka.common.serialization.StringSerializer; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.kafka.core.DefaultKafkaConsumerFactory; import org.springframework.kafka.core.DefaultKafkaProducerFactory; import org.springframework.kafka.core.KafkaTemplate; -import org.springframework.kafka.test.rule.EmbeddedKafkaRule; +import org.springframework.kafka.test.EmbeddedKafkaBroker; +import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.kafka.test.utils.KafkaTestUtils; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; +@EmbeddedKafka(topics = "topic2", count = 1, + bootstrapServersProperty = "spring.cloud.stream.kafka.binder.brokers") @SpringBootTest -@RunWith(SpringRunner.class) public class KafkaNativeSerializationApplicationTests { private static final String INPUT_TOPIC = "topic1"; private static final String OUTPUT_TOPIC = "topic2"; private static final String GROUP_NAME = "nativeSerializationTest"; - @ClassRule - public static EmbeddedKafkaRule embeddedKafka = new EmbeddedKafkaRule(1, true, OUTPUT_TOPIC); - - @BeforeClass - public static void setup() { - System.setProperty("spring.cloud.stream.kafka.binder.brokers", embeddedKafka.getEmbeddedKafka().getBrokersAsString()); - } + @Autowired + EmbeddedKafkaBroker embeddedKafka; @Test public void testSendReceive() { - Map senderProps = KafkaTestUtils.producerProps(embeddedKafka.getEmbeddedKafka()); + Map senderProps = KafkaTestUtils.producerProps(embeddedKafka); senderProps.put("value.serializer", StringSerializer.class); DefaultKafkaProducerFactory pf = new DefaultKafkaProducerFactory<>(senderProps); KafkaTemplate template = new KafkaTemplate<>(pf, true); template.setDefaultTopic(INPUT_TOPIC); template.sendDefault("foo"); - Map consumerProps = KafkaTestUtils.consumerProps(GROUP_NAME, "false", embeddedKafka.getEmbeddedKafka()); + Map consumerProps = KafkaTestUtils.consumerProps(GROUP_NAME, "false", embeddedKafka); consumerProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); consumerProps.put("value.deserializer", MyJsonDeserializer.class); DefaultKafkaConsumerFactory cf = new DefaultKafkaConsumerFactory<>(consumerProps); diff --git a/kafka-security-samples/kafka-ssl-demo/pom.xml b/kafka-security-samples/kafka-ssl-demo/pom.xml index 2652d33a..51b509f3 100644 --- a/kafka-security-samples/kafka-ssl-demo/pom.xml +++ b/kafka-security-samples/kafka-ssl-demo/pom.xml @@ -3,10 +3,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-security-samples + 0.0.1-SNAPSHOT + .. kafka.ssl.demo kafka-ssl-demo @@ -14,22 +14,6 @@ kafka-ssl-demo Demo project for Spring Boot - - 3.1.2 - - - - - - org.springframework.cloud - spring-cloud-stream-dependencies - ${spring-cloud-stream.version} - pom - import - - - - org.springframework.cloud @@ -48,16 +32,10 @@ org.springframework.boot spring-boot-starter-test test - - - org.junit.vintage - junit-vintage-engine - - org.springframework.cloud - spring-cloud-stream-test-support + spring-cloud-stream-test-binder test diff --git a/kafka-security-samples/pom.xml b/kafka-security-samples/pom.xml index 8f0de228..4f5d1234 100644 --- a/kafka-security-samples/pom.xml +++ b/kafka-security-samples/pom.xml @@ -2,6 +2,12 @@ 4.0.0 + + io.spring.cloud.stream.sample + spring-cloud-stream-samples-parent + 0.0.1-SNAPSHOT + .. + io.spring.cloud.stream.sample kafka-security-samples 0.0.1-SNAPSHOT diff --git a/kafka-streams-samples/kafka-streams-aggregate/pom.xml b/kafka-streams-samples/kafka-streams-aggregate/pom.xml index 165fa67b..d653d57a 100644 --- a/kafka-streams-samples/kafka-streams-aggregate/pom.xml +++ b/kafka-streams-samples/kafka-streams-aggregate/pom.xml @@ -11,27 +11,12 @@ Demo project for Spring Boot - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - @@ -65,12 +50,7 @@ org.springframework.boot - spring-boot-starter-web - - - org.junit.vintage - junit-vintage-engine - test + spring-boot-starter-webmvc @@ -84,55 +64,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/kafka-streams-samples/kafka-streams-aggregate/src/main/java/kafka/streams/table/join/KafkaStreamsAggregateSample.java b/kafka-streams-samples/kafka-streams-aggregate/src/main/java/kafka/streams/table/join/KafkaStreamsAggregateSample.java index 15dde85c..50e4dc0b 100644 --- a/kafka-streams-samples/kafka-streams-aggregate/src/main/java/kafka/streams/table/join/KafkaStreamsAggregateSample.java +++ b/kafka-streams-samples/kafka-streams-aggregate/src/main/java/kafka/streams/table/join/KafkaStreamsAggregateSample.java @@ -18,7 +18,6 @@ import java.util.function.Consumer; -import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.kafka.common.serialization.Serde; import org.apache.kafka.common.serialization.Serdes; import org.apache.kafka.common.utils.Bytes; @@ -52,8 +51,7 @@ public static class KafkaStreamsAggregateSampleApplication { @Bean public Consumer> aggregate() { - ObjectMapper mapper = new ObjectMapper(); - Serde domainEventSerde = new JsonSerde<>( DomainEvent.class, mapper ); + Serde domainEventSerde = new JsonSerde<>(DomainEvent.class); return input -> input .groupBy( diff --git a/kafka-streams-samples/kafka-streams-aggregate/src/main/java/kafka/streams/table/join/Producers.java b/kafka-streams-samples/kafka-streams-aggregate/src/main/java/kafka/streams/table/join/Producers.java index c3b6d43f..51d5f440 100644 --- a/kafka-streams-samples/kafka-streams-aggregate/src/main/java/kafka/streams/table/join/Producers.java +++ b/kafka-streams-samples/kafka-streams-aggregate/src/main/java/kafka/streams/table/join/Producers.java @@ -16,7 +16,6 @@ package kafka.streams.table.join; -import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.common.serialization.Serde; import org.apache.kafka.common.serialization.StringSerializer; @@ -34,8 +33,7 @@ public class Producers { public static void main(String... args) { - ObjectMapper mapper = new ObjectMapper(); - Serde domainEventSerde = new JsonSerde<>(DomainEvent.class, mapper); + Serde domainEventSerde = new JsonSerde<>(DomainEvent.class); Map props = new HashMap<>(); diff --git a/kafka-streams-samples/kafka-streams-aggregate/src/test/java/kafka/streams/table/join/KafkaStreamsAggregateSampleTests.java b/kafka-streams-samples/kafka-streams-aggregate/src/test/java/kafka/streams/table/join/KafkaStreamsAggregateSampleTests.java index e6ba52c8..dde33b08 100644 --- a/kafka-streams-samples/kafka-streams-aggregate/src/test/java/kafka/streams/table/join/KafkaStreamsAggregateSampleTests.java +++ b/kafka-streams-samples/kafka-streams-aggregate/src/test/java/kafka/streams/table/join/KafkaStreamsAggregateSampleTests.java @@ -1,43 +1,39 @@ package kafka.streams.table.join; +import java.time.Duration; import java.util.Map; -import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.common.serialization.Serde; import org.apache.kafka.common.serialization.StringSerializer; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.apache.kafka.streams.KafkaStreams; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.ResponseEntity; import org.springframework.kafka.config.StreamsBuilderFactoryBean; import org.springframework.kafka.core.DefaultKafkaProducerFactory; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.support.serializer.JsonSerde; import org.springframework.kafka.test.EmbeddedKafkaBroker; -import org.springframework.kafka.test.rule.EmbeddedKafkaRule; +import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.kafka.test.utils.KafkaTestUtils; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; -@RunWith(SpringRunner.class) +@EmbeddedKafka(topics = "foobar", count = 1, + bootstrapServersProperty = "spring.cloud.stream.kafka.streams.binder.brokers") @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class KafkaStreamsAggregateSampleTests { - @ClassRule - public static EmbeddedKafkaRule embeddedKafkaRule = new EmbeddedKafkaRule(1, true, "foobar"); - - private static EmbeddedKafkaBroker embeddedKafka = embeddedKafkaRule.getEmbeddedKafka(); + @Autowired + EmbeddedKafkaBroker embeddedKafka; @Autowired StreamsBuilderFactoryBean streamsBuilderFactoryBean; @@ -45,26 +41,15 @@ public class KafkaStreamsAggregateSampleTests { @LocalServerPort int randomServerPort; - @Before + @BeforeEach public void before() { streamsBuilderFactoryBean.setCloseTimeout(0); } - @BeforeClass - public static void setUp() { - System.setProperty("spring.cloud.stream.kafka.streams.binder.brokers", embeddedKafka.getBrokersAsString()); - } - - @AfterClass - public static void tearDown() { - System.clearProperty("spring.cloud.stream.kafka.streams.binder.brokers"); - } - @Test public void testKafkaStreamsWordCountProcessor() throws Exception { Map senderProps = KafkaTestUtils.producerProps(embeddedKafka); - ObjectMapper mapper = new ObjectMapper(); - Serde domainEventSerde = new JsonSerde<>(DomainEvent.class, mapper); + Serde domainEventSerde = new JsonSerde<>(DomainEvent.class); senderProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); senderProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, domainEventSerde.serializer().getClass()); @@ -72,7 +57,6 @@ public void testKafkaStreamsWordCountProcessor() throws Exception { DefaultKafkaProducerFactory pf = new DefaultKafkaProducerFactory<>(senderProps); try { - KafkaTemplate template = new KafkaTemplate<>(pf, true); template.setDefaultTopic("foobar"); @@ -81,13 +65,23 @@ public void testKafkaStreamsWordCountProcessor() throws Exception { ddEvent.setEventType("create-domain-event"); template.sendDefault("", ddEvent); - Thread.sleep(1000); + + // Wait for Kafka Streams to reach RUNNING state before querying the state store + await().atMost(Duration.ofSeconds(30)).pollInterval(Duration.ofMillis(500)).until(() -> { + KafkaStreams kafkaStreams = streamsBuilderFactoryBean.getKafkaStreams(); + return kafkaStreams != null && kafkaStreams.state() == KafkaStreams.State.RUNNING; + }); + RestTemplate restTemplate = new RestTemplate(); String fooResourceUrl = "http://localhost:" + randomServerPort + "/events"; - ResponseEntity response - = restTemplate.getForEntity(fooResourceUrl, String.class); - assertThat(response.getBody()).contains("create-domain-event"); + + // Poll for the result since the state store may need time to process the record + await().atMost(Duration.ofSeconds(30)).pollInterval(Duration.ofMillis(500)).untilAsserted(() -> { + ResponseEntity response + = restTemplate.getForEntity(fooResourceUrl, String.class); + assertThat(response.getBody()).contains("create-domain-event"); + }); } finally { pf.destroy(); diff --git a/kafka-streams-samples/kafka-streams-avro/pom.xml b/kafka-streams-samples/kafka-streams-avro/pom.xml index 1ffa3316..997d09f7 100644 --- a/kafka-streams-samples/kafka-streams-avro/pom.xml +++ b/kafka-streams-samples/kafka-streams-avro/pom.xml @@ -3,10 +3,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. com.example kafka-streams-avro @@ -14,9 +14,7 @@ kafka-streams-avro Demo project for Spring Boot - 8 - 2020.0.2 - 5.2.0 + 7.9.0 1.11.3 @@ -31,7 +29,6 @@ org.springframework.cloud spring-cloud-stream-binder-kafka-streams - 3.1.3-SNAPSHOT @@ -46,10 +43,8 @@ org.springframework.cloud - spring-cloud-stream + spring-cloud-stream-test-binder test - test-binder - test-jar org.apache.avro @@ -78,18 +73,6 @@ ${confluent.version} - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - diff --git a/kafka-streams-samples/kafka-streams-branching/pom.xml b/kafka-streams-samples/kafka-streams-branching/pom.xml index 690c8d1a..0fb480f9 100644 --- a/kafka-streams-samples/kafka-streams-branching/pom.xml +++ b/kafka-streams-samples/kafka-streams-branching/pom.xml @@ -11,27 +11,12 @@ Demo project for Spring Boot - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - @@ -65,12 +50,7 @@ org.springframework.boot - spring-boot-starter-web - - - org.junit.vintage - junit-vintage-engine - test + spring-boot-starter-webmvc @@ -83,54 +63,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - + diff --git a/kafka-streams-samples/kafka-streams-branching/src/main/java/kafka/streams/branching/KafkaStreamsBranchingSample.java b/kafka-streams-samples/kafka-streams-branching/src/main/java/kafka/streams/branching/KafkaStreamsBranchingSample.java index 5d3e87f8..4c0c8bec 100644 --- a/kafka-streams-samples/kafka-streams-branching/src/main/java/kafka/streams/branching/KafkaStreamsBranchingSample.java +++ b/kafka-streams-samples/kafka-streams-branching/src/main/java/kafka/streams/branching/KafkaStreamsBranchingSample.java @@ -19,12 +19,14 @@ import java.time.Duration; import java.util.Arrays; import java.util.Date; +import java.util.Map; import java.util.function.Function; import org.apache.kafka.streams.KeyValue; +import org.apache.kafka.streams.kstream.Branched; import org.apache.kafka.streams.kstream.KStream; import org.apache.kafka.streams.kstream.Materialized; -import org.apache.kafka.streams.kstream.Predicate; +import org.apache.kafka.streams.kstream.Named; import org.apache.kafka.streams.kstream.TimeWindows; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -43,19 +45,29 @@ public static class WordCountProcessorApplication { @SuppressWarnings("unchecked") public Function, KStream[]> process() { - Predicate isEnglish = (k, v) -> v.word.equals("english"); - Predicate isFrench = (k, v) -> v.word.equals("french"); - Predicate isSpanish = (k, v) -> v.word.equals("spanish"); - - return input -> input - .flatMapValues(value -> Arrays.asList(value.toLowerCase().split("\\W+"))) - .groupBy((key, value) -> value) - .windowedBy(TimeWindows.of(Duration.ofSeconds(6))) - .count(Materialized.as("WordCounts-1")) - .toStream() - .map((key, value) -> new KeyValue<>(null, - new WordCount(key.key(), value, new Date(key.window().start()), new Date(key.window().end())))) - .branch(isEnglish, isFrench, isSpanish); + return input -> { + KStream wordCounts = input + .flatMapValues(value -> Arrays.asList(value.toLowerCase().split("\\W+"))) + .groupBy((key, value) -> value) + .windowedBy(TimeWindows.ofSizeWithNoGrace(Duration.ofSeconds(6))) + .count(Materialized.as("WordCounts-1")) + .toStream() + .map((key, value) -> new KeyValue<>(null, + new WordCount(key.key(), value, new Date(key.window().start()), new Date(key.window().end())))); + + Map> branches = wordCounts + .split(Named.as("branch-")) + .branch((k, v) -> v.word.equals("english"), Branched.as("english")) + .branch((k, v) -> v.word.equals("french"), Branched.as("french")) + .branch((k, v) -> v.word.equals("spanish"), Branched.as("spanish")) + .noDefaultBranch(); + + return new KStream[]{ + branches.get("branch-english"), + branches.get("branch-french"), + branches.get("branch-spanish") + }; + }; } } diff --git a/kafka-streams-samples/kafka-streams-branching/src/test/java/kafka/streams/branching/KafkaStreamsBranchingSampleTests.java b/kafka-streams-samples/kafka-streams-branching/src/test/java/kafka/streams/branching/KafkaStreamsBranchingSampleTests.java index c9c9b5f6..9412e640 100644 --- a/kafka-streams-samples/kafka-streams-branching/src/test/java/kafka/streams/branching/KafkaStreamsBranchingSampleTests.java +++ b/kafka-streams-samples/kafka-streams-branching/src/test/java/kafka/streams/branching/KafkaStreamsBranchingSampleTests.java @@ -16,17 +16,18 @@ package kafka.streams.branching; +import java.time.Duration; import java.util.Map; import org.apache.kafka.clients.consumer.Consumer; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.consumer.ConsumerRecord; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.kafka.config.StreamsBuilderFactoryBean; @@ -34,47 +35,43 @@ import org.springframework.kafka.core.DefaultKafkaProducerFactory; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.test.EmbeddedKafkaBroker; -import org.springframework.kafka.test.rule.EmbeddedKafkaRule; +import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.kafka.test.utils.KafkaTestUtils; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(SpringRunner.class) +@EmbeddedKafka(topics = {"words", "english-counts", "french-counts", "spanish-counts"}, count = 1, + bootstrapServersProperty = "spring.cloud.stream.kafka.streams.binder.brokers") @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.NONE) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class KafkaStreamsBranchingSampleTests { - @ClassRule - public static EmbeddedKafkaRule embeddedKafkaRule = new EmbeddedKafkaRule(1, true, "words", - "english-counts", "french-counts", "spanish-counts"); - - private static EmbeddedKafkaBroker embeddedKafka = embeddedKafkaRule.getEmbeddedKafka(); + @Autowired + EmbeddedKafkaBroker embeddedKafka; - private static Consumer consumer; + private Consumer consumer; @Autowired StreamsBuilderFactoryBean streamsBuilderFactoryBean; - @Before + @BeforeEach public void before() { streamsBuilderFactoryBean.setCloseTimeout(0); } - @BeforeClass - public static void setUp() { + @BeforeAll + void setUp() { Map consumerProps = KafkaTestUtils.consumerProps("group", "false", embeddedKafka); consumerProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); DefaultKafkaConsumerFactory cf = new DefaultKafkaConsumerFactory<>(consumerProps); consumer = cf.createConsumer(); embeddedKafka.consumeFromEmbeddedTopics(consumer, "english-counts", "french-counts", "spanish-counts"); - System.setProperty("spring.cloud.stream.kafka.streams.binder.brokers", embeddedKafka.getBrokersAsString()); } - @AfterClass - public static void tearDown() { + @AfterAll + void tearDown() { consumer.close(); - System.clearProperty("spring.cloud.stream.kafka.streams.binder.brokers"); } @Test @@ -88,11 +85,11 @@ public void testKafkaStreamsWordCountProcessor() throws InterruptedException { template.sendDefault("french"); template.sendDefault("spanish"); Thread.sleep(2000); - ConsumerRecord cr = KafkaTestUtils.getSingleRecord(consumer, "english-counts", 5000); + ConsumerRecord cr = KafkaTestUtils.getSingleRecord(consumer, "english-counts", Duration.ofSeconds(5)); assertThat(cr.value().contains("english")).isTrue(); - cr = KafkaTestUtils.getSingleRecord(consumer, "french-counts", 5000); + cr = KafkaTestUtils.getSingleRecord(consumer, "french-counts", Duration.ofSeconds(5)); assertThat(cr.value().contains("french")).isTrue(); - cr = KafkaTestUtils.getSingleRecord(consumer, "spanish-counts", 5000); + cr = KafkaTestUtils.getSingleRecord(consumer, "spanish-counts", Duration.ofSeconds(5)); assertThat(cr.value().contains("spanish")).isTrue(); } finally { @@ -100,4 +97,4 @@ public void testKafkaStreamsWordCountProcessor() throws InterruptedException { } } -} \ No newline at end of file +} diff --git a/kafka-streams-samples/kafka-streams-destination-pattern/pom.xml b/kafka-streams-samples/kafka-streams-destination-pattern/pom.xml index 050418da..6280827a 100644 --- a/kafka-streams-samples/kafka-streams-destination-pattern/pom.xml +++ b/kafka-streams-samples/kafka-streams-destination-pattern/pom.xml @@ -3,10 +3,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. com.example kafka-streams-destination-pattern @@ -14,10 +14,6 @@ kafka-streams-destination-pattern Demo project for Spring Boot - - 2020.0.2 - 1.1.0 - @@ -38,32 +34,14 @@ org.springframework.boot spring-boot-starter-test test - - - org.junit.vintage - junit-vintage-engine - - org.springframework.cloud - spring-cloud-stream-test-support + spring-cloud-stream-test-binder test - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - diff --git a/kafka-streams-samples/kafka-streams-dlq-sample/pom.xml b/kafka-streams-samples/kafka-streams-dlq-sample/pom.xml index 7c42eb17..99aff37f 100644 --- a/kafka-streams-samples/kafka-streams-dlq-sample/pom.xml +++ b/kafka-streams-samples/kafka-streams-dlq-sample/pom.xml @@ -11,27 +11,12 @@ Demo project for Spring Boot - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - @@ -65,12 +50,7 @@ org.springframework.boot - spring-boot-starter-web - - - org.junit.vintage - junit-vintage-engine - test + spring-boot-starter-webmvc @@ -83,55 +63,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/kafka-streams-samples/kafka-streams-dlq-sample/src/main/java/kafka/streams/dlq/sample/KafkaStreamsDlqSample.java b/kafka-streams-samples/kafka-streams-dlq-sample/src/main/java/kafka/streams/dlq/sample/KafkaStreamsDlqSample.java index cc75398e..1f1a88db 100644 --- a/kafka-streams-samples/kafka-streams-dlq-sample/src/main/java/kafka/streams/dlq/sample/KafkaStreamsDlqSample.java +++ b/kafka-streams-samples/kafka-streams-dlq-sample/src/main/java/kafka/streams/dlq/sample/KafkaStreamsDlqSample.java @@ -16,6 +16,7 @@ package kafka.streams.dlq.sample; +import java.time.Duration; import java.util.Arrays; import java.util.Date; import java.util.function.Function; @@ -46,7 +47,7 @@ public Function,KStream> process() { .flatMapValues(value -> Arrays.asList(value.toLowerCase().split("\\W+"))) .map((key, value) -> new KeyValue<>(value, value)) .groupByKey(Grouped.with(Serdes.String(), Serdes.String())) - .windowedBy(TimeWindows.of(5000)) + .windowedBy(TimeWindows.ofSizeWithNoGrace(Duration.ofMillis(5000))) .count(Materialized.as("WordCounts-1")) .toStream() .map((key, value) -> new KeyValue<>(null, diff --git a/kafka-streams-samples/kafka-streams-dlq-sample/src/main/resources/application.yml b/kafka-streams-samples/kafka-streams-dlq-sample/src/main/resources/application.yml index 28f72d1b..98a82dde 100644 --- a/kafka-streams-samples/kafka-streams-dlq-sample/src/main/resources/application.yml +++ b/kafka-streams-samples/kafka-streams-dlq-sample/src/main/resources/application.yml @@ -4,7 +4,7 @@ spring.cloud.stream.kafka.streams.binder: default.key.serde: org.apache.kafka.common.serialization.Serdes$StringSerde default.value.serde: org.apache.kafka.common.serialization.Serdes$IntegerSerde application.id: dlq-demo-sample - serdeError: sendToDlq + deserializationExceptionHandler: sendToDlq spring.cloud.stream.bindings.process-out-0: destination: counts spring.cloud.stream.bindings.process-in-0: diff --git a/kafka-streams-samples/kafka-streams-dlq-sample/src/test/java/kafka/streams/dlq/sample/KafkaStreamsDlqExampleTests.java b/kafka-streams-samples/kafka-streams-dlq-sample/src/test/java/kafka/streams/dlq/sample/KafkaStreamsDlqExampleTests.java index cd193deb..11957577 100644 --- a/kafka-streams-samples/kafka-streams-dlq-sample/src/test/java/kafka/streams/dlq/sample/KafkaStreamsDlqExampleTests.java +++ b/kafka-streams-samples/kafka-streams-dlq-sample/src/test/java/kafka/streams/dlq/sample/KafkaStreamsDlqExampleTests.java @@ -5,47 +5,45 @@ import org.apache.kafka.clients.consumer.Consumer; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.consumer.ConsumerRecords; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; + +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.kafka.core.DefaultKafkaConsumerFactory; import org.springframework.kafka.core.DefaultKafkaProducerFactory; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.test.EmbeddedKafkaBroker; -import org.springframework.kafka.test.rule.EmbeddedKafkaRule; +import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.kafka.test.utils.KafkaTestUtils; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(SpringRunner.class) +@EmbeddedKafka(topics = {"words", "words-count-dlq"}, count = 1, + bootstrapServersProperty = "spring.cloud.stream.kafka.streams.binder.brokers") @SpringBootTest +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class KafkaStreamsDlqExampleTests { - @ClassRule - public static EmbeddedKafkaRule embeddedKafkaRule = new EmbeddedKafkaRule(1, true, "words", "words-count-dlq"); - - private static EmbeddedKafkaBroker embeddedKafka = embeddedKafkaRule.getEmbeddedKafka(); + @Autowired + EmbeddedKafkaBroker embeddedKafka; - private static Consumer consumer; + private Consumer consumer; - @BeforeClass - public static void setUp() { + @BeforeAll + void setUp() { Map consumerProps = KafkaTestUtils.consumerProps("group", "false", embeddedKafka); consumerProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); DefaultKafkaConsumerFactory cf = new DefaultKafkaConsumerFactory<>(consumerProps); consumer = cf.createConsumer(); embeddedKafka.consumeFromAnEmbeddedTopic(consumer, "words-count-dlq"); - System.setProperty("spring.cloud.stream.kafka.streams.binder.brokers", embeddedKafka.getBrokersAsString()); } - @AfterClass - public static void tearDown() { + @AfterAll + void tearDown() { consumer.close(); - System.clearProperty("spring.cloud.stream.kafka.streams.binder.brokers"); } @Test diff --git a/kafka-streams-samples/kafka-streams-global-table-join/pom.xml b/kafka-streams-samples/kafka-streams-global-table-join/pom.xml index 9b43b748..46625bc8 100644 --- a/kafka-streams-samples/kafka-streams-global-table-join/pom.xml +++ b/kafka-streams-samples/kafka-streams-global-table-join/pom.xml @@ -11,27 +11,12 @@ Demo project for Spring Boot - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - @@ -66,7 +51,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -80,55 +65,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/kafka-streams-samples/kafka-streams-interactive-query/pom.xml b/kafka-streams-samples/kafka-streams-interactive-query/pom.xml index 56de4498..79079444 100644 --- a/kafka-streams-samples/kafka-streams-interactive-query/pom.xml +++ b/kafka-streams-samples/kafka-streams-interactive-query/pom.xml @@ -9,9 +9,9 @@ io.spring.cloud.stream.sample - spring-cloud-stream-samples-parent + kafka-streams-samples 0.0.1-SNAPSHOT - ../.. + .. @@ -21,22 +21,10 @@ 17 - - - - org.springframework.cloud - spring-cloud-stream-dependencies - ${spring-cloud-stream.version} - pom - import - - - - org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc org.springframework.cloud @@ -55,53 +43,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - - spring-milestones - Spring milestones - https://repo.spring.io/libs-milestone-local - - - rsocket-snapshots - RSocket Snapshots - https://oss.jfrog.org/oss-snapshot-local - - true - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - diff --git a/kafka-streams-samples/kafka-streams-inventory-count/pom.xml b/kafka-streams-samples/kafka-streams-inventory-count/pom.xml index ac3092bc..fda1093c 100644 --- a/kafka-streams-samples/kafka-streams-inventory-count/pom.xml +++ b/kafka-streams-samples/kafka-streams-inventory-count/pom.xml @@ -8,39 +8,20 @@ Kafka Streams inventory count sample - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - 2.6.0 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud spring-cloud-stream-binder-kafka-streams - 3.1.3-SNAPSHOT org.springframework.cloud spring-cloud-stream - 3.1.3-SNAPSHOT org.springframework.boot @@ -56,7 +37,6 @@ org.apache.kafka kafka-streams-test-utils - ${kafka-streams-test-utils.version} test @@ -71,55 +51,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/AbstractInventoryCountTests.java b/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/AbstractInventoryCountTests.java index 5c7af106..ada2073a 100644 --- a/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/AbstractInventoryCountTests.java +++ b/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/AbstractInventoryCountTests.java @@ -15,6 +15,7 @@ */ package kafka.streams.inventory.count; +import java.time.Duration; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; @@ -134,7 +135,7 @@ protected Map consumeActualInventoryCountEvents Map inventoryCountEvents = new LinkedHashMap<>(); int receivedCount = 0; while (receivedCount < expectedCount) { - ConsumerRecords records = KafkaTestUtils.getRecords(consumer, 1000); + ConsumerRecords records = KafkaTestUtils.getRecords(consumer, Duration.ofMillis(1000)); if (records.isEmpty()) { logger.error("No more records received. Expected {} received {}.", expectedCount, receivedCount); break; diff --git a/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/KafkaStreamsInventoryCountTests.java b/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/KafkaStreamsInventoryCountTests.java index d281e2be..9f5bd9b1 100644 --- a/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/KafkaStreamsInventoryCountTests.java +++ b/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/KafkaStreamsInventoryCountTests.java @@ -81,9 +81,10 @@ public static void init(EmbeddedKafkaBroker embeddedKafka) { */ context = new SpringApplicationBuilder(KafkaStreamsInventoryCountApplication.class) .properties( + "server.port=0", "spring.cloud.stream.kafka.streams.binder.brokers=" + embeddedKafka.getBrokersAsString(), "spring.cloud.stream.kafka.streams.binder.configuration.commit.interval.ms=1000", - "spring.cloud.stream.kafka.streams.binder.configuration.cache.max.bytes.buffering=0") + "spring.cloud.stream.kafka.streams.binder.configuration.statestore.cache.max.bytes=0") .run(); } diff --git a/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/SpringBootKafkaStreamsInventoryCountTests.java b/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/SpringBootKafkaStreamsInventoryCountTests.java index fd4475cd..cf60230c 100644 --- a/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/SpringBootKafkaStreamsInventoryCountTests.java +++ b/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/SpringBootKafkaStreamsInventoryCountTests.java @@ -55,9 +55,10 @@ * More messages are produced on the output topic. */ @SpringBootTest( + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "spring.cloud.stream.kafka.streams.binder.configuration.commit.interval.ms=1000", - "spring.cloud.stream.kafka.streams.binder.configuration.cache.max.bytes.buffering=0" + "spring.cloud.stream.kafka.streams.binder.configuration.statestore.cache.max.bytes=0" }) @DirtiesContext public class SpringBootKafkaStreamsInventoryCountTests extends AbstractInventoryCountTests { diff --git a/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/TopolologyTestDriverKafkaStreamsInventoryCountTests.java b/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/TopolologyTestDriverKafkaStreamsInventoryCountTests.java index 8f26b442..31613205 100644 --- a/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/TopolologyTestDriverKafkaStreamsInventoryCountTests.java +++ b/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/TopolologyTestDriverKafkaStreamsInventoryCountTests.java @@ -21,11 +21,12 @@ import java.util.Properties; import kafka.streams.inventory.count.KafkaStreamsInventoryCountApplication.KafkaStreamsInventoryAggregator; import kafka.streams.inventory.count.generator.TopologyTestDriverUpdateEventGenerator; -import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.serialization.Deserializer; import org.apache.kafka.common.serialization.Serde; +import org.apache.kafka.streams.KeyValue; import org.apache.kafka.streams.StreamsBuilder; import org.apache.kafka.streams.StreamsConfig; +import org.apache.kafka.streams.TestOutputTopic; import org.apache.kafka.streams.Topology; import org.apache.kafka.streams.TopologyTestDriver; import org.apache.kafka.streams.kstream.Consumed; @@ -56,6 +57,7 @@ public class TopolologyTestDriverKafkaStreamsInventoryCountTests extends Abstrac private Serde keySerde = new JsonSerde<>(ProductKey.class); private TopologyTestDriver testDriver; + private TestOutputTopic outputTopic; static Properties getStreamsConfiguration() { final Properties streamsConfiguration = new Properties(); @@ -90,6 +92,7 @@ void setup() { logger.debug(topology.describe().toString()); + outputTopic = testDriver.createOutputTopic(OUTPUT_TOPIC, keySerde.deserializer(), countEventSerde.deserializer()); setEventGenerator(new TopologyTestDriverUpdateEventGenerator(testDriver, INPUT_TOPIC, keySerde.serializer(), updateEventSerde.serializer())); @@ -112,14 +115,13 @@ protected Map consumeActualInventoryCountEvents Map inventoryCountEvents = new LinkedHashMap<>(); int receivedCount = 0; while (receivedCount < expectedCount) { - ProducerRecord record - = testDriver.readOutput(OUTPUT_TOPIC, keySerde.deserializer(), countEventSerde.deserializer()); - if (record == null) { + if (outputTopic.isEmpty()) { break; } + KeyValue record = outputTopic.readKeyValue(); receivedCount++; - logger.debug("consumed " + record.key().getProductCode() + " = " + record.value().getCount()); - inventoryCountEvents.put(record.key(), record.value()); + logger.debug("consumed " + record.key.getProductCode() + " = " + record.value.getCount()); + inventoryCountEvents.put(record.key, record.value); } return inventoryCountEvents; } diff --git a/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/generator/TopologyTestDriverUpdateEventGenerator.java b/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/generator/TopologyTestDriverUpdateEventGenerator.java index 7c2a5546..d6238414 100644 --- a/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/generator/TopologyTestDriverUpdateEventGenerator.java +++ b/kafka-streams-samples/kafka-streams-inventory-count/src/test/java/kafka/streams/inventory/count/generator/TopologyTestDriverUpdateEventGenerator.java @@ -15,14 +15,11 @@ */ package kafka.streams.inventory.count.generator; -import java.time.LocalDateTime; -import java.time.ZoneOffset; import kafka.streams.inventory.count.InventoryUpdateEvent; import kafka.streams.inventory.count.ProductKey; -import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.common.serialization.Serializer; +import org.apache.kafka.streams.TestInputTopic; import org.apache.kafka.streams.TopologyTestDriver; -import org.apache.kafka.streams.test.ConsumerRecordFactory; /** * Test data generator using {@link InventoryUpdateEvent}s using {@link TopologyTestDriver} to send events. @@ -32,21 +29,17 @@ */ public class TopologyTestDriverUpdateEventGenerator extends AbstractInventoryUpdateEventGenerator { - private final TopologyTestDriver topologyTestDriver; - private final ConsumerRecordFactory recordFactory; + private final TestInputTopic inputTopic; public TopologyTestDriverUpdateEventGenerator(TopologyTestDriver topologyTestDriver, - String inputTopic, + String inputTopicName, Serializer keySerializer, Serializer valueSerializer) { - this.topologyTestDriver = topologyTestDriver; - this.recordFactory = new ConsumerRecordFactory<>( - inputTopic, keySerializer, valueSerializer); + this.inputTopic = topologyTestDriver.createInputTopic(inputTopicName, keySerializer, valueSerializer); } @Override protected void doSendEvent(ProductKey key, InventoryUpdateEvent value) { - ConsumerRecord record = recordFactory.create(key, value, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)); - topologyTestDriver.pipeInput(record); + inputTopic.pipeInput(key, value); } } diff --git a/kafka-streams-samples/kafka-streams-jaas-security/pom.xml b/kafka-streams-samples/kafka-streams-jaas-security/pom.xml index 14db7ac3..b65517dc 100644 --- a/kafka-streams-samples/kafka-streams-jaas-security/pom.xml +++ b/kafka-streams-samples/kafka-streams-jaas-security/pom.xml @@ -10,27 +10,12 @@ Demo project for Spring Boot - org.springframework.boot - spring-boot-starter-parent - 3.0.13 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. - - 2022.0.5 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - @@ -68,12 +53,7 @@ org.springframework.boot - spring-boot-starter-web - - - org.junit.vintage - junit-vintage-engine - test + spring-boot-starter-webmvc @@ -86,55 +66,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/kafka-streams-samples/kafka-streams-jaas-security/src/main/java/kafka/streams/word/count/KafkaStreamsWordCountApplication.java b/kafka-streams-samples/kafka-streams-jaas-security/src/main/java/kafka/streams/word/count/KafkaStreamsWordCountApplication.java index c4d8fc35..975f2ca8 100644 --- a/kafka-streams-samples/kafka-streams-jaas-security/src/main/java/kafka/streams/word/count/KafkaStreamsWordCountApplication.java +++ b/kafka-streams-samples/kafka-streams-jaas-security/src/main/java/kafka/streams/word/count/KafkaStreamsWordCountApplication.java @@ -52,7 +52,7 @@ public Function, KStream> process() { .flatMapValues(value -> Arrays.asList(value.toLowerCase().split("\\W+"))) .map((key, value) -> new KeyValue<>(value, value)) .groupByKey(Grouped.with(Serdes.String(), Serdes.String())) - .windowedBy(TimeWindows.of(Duration.ofMillis(WINDOW_SIZE_MS))) + .windowedBy(TimeWindows.ofSizeWithNoGrace(Duration.ofMillis(WINDOW_SIZE_MS))) .count(Materialized.as("WordCounts-1")) .toStream() .map((key, value) -> new KeyValue<>(null, new WordCount(key.key(), value, new Date(key.window().start()), new Date(key.window().end())))); diff --git a/kafka-streams-samples/kafka-streams-message-channel/pom.xml b/kafka-streams-samples/kafka-streams-message-channel/pom.xml index 6d82ecee..94284236 100644 --- a/kafka-streams-samples/kafka-streams-message-channel/pom.xml +++ b/kafka-streams-samples/kafka-streams-message-channel/pom.xml @@ -11,27 +11,12 @@ Demo project for Spring Boot - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - @@ -70,7 +55,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -84,54 +69,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - + diff --git a/kafka-streams-samples/kafka-streams-message-channel/src/main/java/kafka/streams/message/channel/KafkaStreamsWordCountApplication.java b/kafka-streams-samples/kafka-streams-message-channel/src/main/java/kafka/streams/message/channel/KafkaStreamsWordCountApplication.java index c0db086e..164c2db5 100644 --- a/kafka-streams-samples/kafka-streams-message-channel/src/main/java/kafka/streams/message/channel/KafkaStreamsWordCountApplication.java +++ b/kafka-streams-samples/kafka-streams-message-channel/src/main/java/kafka/streams/message/channel/KafkaStreamsWordCountApplication.java @@ -48,7 +48,7 @@ public Function, KStream> process() { .flatMapValues(value -> Arrays.asList(value.toLowerCase().split("\\W+"))) .map((key, value) -> new KeyValue<>(value, value)) .groupByKey(Grouped.with(Serdes.String(), Serdes.String())) - .windowedBy(TimeWindows.of(Duration.ofSeconds(60))) + .windowedBy(TimeWindows.ofSizeWithNoGrace(Duration.ofSeconds(60))) .count(Materialized.as("WordCounts-1")) .toStream() .map((key, value) -> new KeyValue<>(null, diff --git a/kafka-streams-samples/kafka-streams-metrics-demo/pom.xml b/kafka-streams-samples/kafka-streams-metrics-demo/pom.xml index 44cf8b0c..274babd1 100644 --- a/kafka-streams-samples/kafka-streams-metrics-demo/pom.xml +++ b/kafka-streams-samples/kafka-streams-metrics-demo/pom.xml @@ -3,10 +3,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. com.example kafka-streams-metrics-demo @@ -14,10 +14,6 @@ kafka-streams-metrics-demo Demo project for Spring Boot - - 2020.0.2 - 1.1.0 - @@ -39,50 +35,26 @@ org.springframework.boot spring-boot-starter-test test - - - org.junit.vintage - junit-vintage-engine - - org.springframework.cloud - spring-cloud-stream-test-support + spring-cloud-stream-test-binder test io.micrometer micrometer-registry-prometheus - - io.micrometer.prometheus - prometheus-rsocket-spring - ${prometheus-rsocket.version} - - org.springframework.boot spring-boot-starter-actuator org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - diff --git a/kafka-streams-samples/kafka-streams-multiple-input-topics/pom.xml b/kafka-streams-samples/kafka-streams-multiple-input-topics/pom.xml index af701bfd..3e795ba4 100644 --- a/kafka-streams-samples/kafka-streams-multiple-input-topics/pom.xml +++ b/kafka-streams-samples/kafka-streams-multiple-input-topics/pom.xml @@ -3,19 +3,16 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.5.4 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. com.example kafka-streams-multiple-input-topics 0.0.1-SNAPSHOT kafka-streams-multiple-input-topics Demo project for Spring Boot - - 2020.0.3 - org.apache.kafka @@ -37,24 +34,10 @@ org.springframework.cloud - spring-cloud-stream + spring-cloud-stream-test-binder test - test-binder - test-jar - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - diff --git a/kafka-streams-samples/kafka-streams-product-tracker/pom.xml b/kafka-streams-samples/kafka-streams-product-tracker/pom.xml index 5d5a38d0..34ca7828 100644 --- a/kafka-streams-samples/kafka-streams-product-tracker/pom.xml +++ b/kafka-streams-samples/kafka-streams-product-tracker/pom.xml @@ -11,27 +11,12 @@ Demo project for Spring Boot - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - @@ -66,7 +51,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -79,54 +64,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - + diff --git a/kafka-streams-samples/kafka-streams-product-tracker/src/main/java/kafka/streams/product/tracker/KafkaStreamsProductTrackerApplication.java b/kafka-streams-samples/kafka-streams-product-tracker/src/main/java/kafka/streams/product/tracker/KafkaStreamsProductTrackerApplication.java index 39113df4..7bf3ce70 100644 --- a/kafka-streams-samples/kafka-streams-product-tracker/src/main/java/kafka/streams/product/tracker/KafkaStreamsProductTrackerApplication.java +++ b/kafka-streams-samples/kafka-streams-product-tracker/src/main/java/kafka/streams/product/tracker/KafkaStreamsProductTrackerApplication.java @@ -57,7 +57,7 @@ public Function, KStream> proce .filter((key, product) -> productIds().contains(product.getId())) .map((key, value) -> new KeyValue<>(value, value)) .groupByKey(Grouped.with(new JsonSerde<>(Product.class), new JsonSerde<>(Product.class))) - .windowedBy(TimeWindows.of(Duration.ofSeconds(60))) + .windowedBy(TimeWindows.ofSizeWithNoGrace(Duration.ofSeconds(60))) .count(Materialized.as("product-counts")) .toStream() .map((key, value) -> new KeyValue<>(key.key().id, new ProductStatus(key.key().id, diff --git a/kafka-streams-samples/kafka-streams-recoverable/pom.xml b/kafka-streams-samples/kafka-streams-recoverable/pom.xml index a87bff5c..671024f6 100644 --- a/kafka-streams-samples/kafka-streams-recoverable/pom.xml +++ b/kafka-streams-samples/kafka-streams-recoverable/pom.xml @@ -11,27 +11,12 @@ Demo project for Spring Boot - org.springframework.boot - spring-boot-starter-parent - 3.2.0 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. - - 2023.0.0 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - @@ -77,7 +62,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -90,55 +75,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/kafka-streams-samples/kafka-streams-table-join/pom.xml b/kafka-streams-samples/kafka-streams-table-join/pom.xml index 5e110b4d..84127126 100644 --- a/kafka-streams-samples/kafka-streams-table-join/pom.xml +++ b/kafka-streams-samples/kafka-streams-table-join/pom.xml @@ -11,27 +11,12 @@ Demo project for Spring Boot - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - @@ -66,7 +51,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -80,55 +65,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/kafka-streams-samples/kafka-streams-to-rabbitmq-message-channel/pom.xml b/kafka-streams-samples/kafka-streams-to-rabbitmq-message-channel/pom.xml index 77046589..387e008d 100644 --- a/kafka-streams-samples/kafka-streams-to-rabbitmq-message-channel/pom.xml +++ b/kafka-streams-samples/kafka-streams-to-rabbitmq-message-channel/pom.xml @@ -11,27 +11,12 @@ Demo project for Spring Boot - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - @@ -73,7 +58,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -87,54 +72,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - + diff --git a/kafka-streams-samples/kafka-streams-to-rabbitmq-message-channel/src/main/java/kafka/streams/message/channel/KafkaStreamsWordCountApplication.java b/kafka-streams-samples/kafka-streams-to-rabbitmq-message-channel/src/main/java/kafka/streams/message/channel/KafkaStreamsWordCountApplication.java index 85408330..9ec035bf 100644 --- a/kafka-streams-samples/kafka-streams-to-rabbitmq-message-channel/src/main/java/kafka/streams/message/channel/KafkaStreamsWordCountApplication.java +++ b/kafka-streams-samples/kafka-streams-to-rabbitmq-message-channel/src/main/java/kafka/streams/message/channel/KafkaStreamsWordCountApplication.java @@ -48,7 +48,7 @@ public Function, KStream> process() { .flatMapValues(value -> Arrays.asList(value.toLowerCase().split("\\W+"))) .map((key, value) -> new KeyValue<>(value, value)) .groupByKey(Grouped.with(Serdes.String(), Serdes.String())) - .windowedBy(TimeWindows.of(Duration.ofSeconds(20))) + .windowedBy(TimeWindows.ofSizeWithNoGrace(Duration.ofSeconds(20))) .count(Materialized.as("WordCounts-1")) .toStream() .map((key, value) -> new KeyValue<>(null, new WordCount(key.key(), value, new Date(key.window().start()), new Date(key.window().end())))); diff --git a/kafka-streams-samples/kafka-streams-word-count/pom.xml b/kafka-streams-samples/kafka-streams-word-count/pom.xml index cb5ecfb8..5f6e024f 100644 --- a/kafka-streams-samples/kafka-streams-word-count/pom.xml +++ b/kafka-streams-samples/kafka-streams-word-count/pom.xml @@ -10,42 +10,18 @@ Demo project for Spring Boot - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-streams-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - io.micrometer micrometer-registry-prometheus - - io.micrometer - micrometer-registry-wavefront - - - io.micrometer.prometheus - prometheus-rsocket-spring - 1.2.1 - org.springframework.cloud spring-cloud-stream-binder-kafka-streams @@ -77,12 +53,7 @@ org.springframework.boot - spring-boot-starter-web - - - org.junit.vintage - junit-vintage-engine - test + spring-boot-starter-webmvc @@ -116,55 +87,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/kafka-streams-samples/kafka-streams-word-count/src/main/java/kafka/streams/word/count/KafkaStreamsWordCountApplication.java b/kafka-streams-samples/kafka-streams-word-count/src/main/java/kafka/streams/word/count/KafkaStreamsWordCountApplication.java index 9d93adef..faee46bf 100644 --- a/kafka-streams-samples/kafka-streams-word-count/src/main/java/kafka/streams/word/count/KafkaStreamsWordCountApplication.java +++ b/kafka-streams-samples/kafka-streams-word-count/src/main/java/kafka/streams/word/count/KafkaStreamsWordCountApplication.java @@ -53,7 +53,7 @@ public Function, KStream> process() { .flatMapValues(value -> Arrays.asList(value.toLowerCase().split("\\W+"))) .map((key, value) -> new KeyValue<>(value, value)) .groupByKey(Grouped.with(Serdes.String(), Serdes.String())) - .windowedBy(TimeWindows.of(Duration.ofMillis(WINDOW_SIZE_MS))) + .windowedBy(TimeWindows.ofSizeWithNoGrace(Duration.ofMillis(WINDOW_SIZE_MS))) .count(Materialized.as("WordCounts-1")) .toStream() .map((key, value) -> new KeyValue<>(null, new WordCount(key.key(), value, new Date(key.window().start()), new Date(key.window().end())))); diff --git a/kafka-streams-samples/kafka-streams-word-count/src/test/java/kafka/streams/word/count/KafkaStreamsWordCountApplicationTests.java b/kafka-streams-samples/kafka-streams-word-count/src/test/java/kafka/streams/word/count/KafkaStreamsWordCountApplicationTests.java index d4d4b4d4..0366bfc6 100644 --- a/kafka-streams-samples/kafka-streams-word-count/src/test/java/kafka/streams/word/count/KafkaStreamsWordCountApplicationTests.java +++ b/kafka-streams-samples/kafka-streams-word-count/src/test/java/kafka/streams/word/count/KafkaStreamsWordCountApplicationTests.java @@ -21,12 +21,12 @@ import org.apache.kafka.clients.consumer.Consumer; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.consumer.ConsumerRecords; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.kafka.config.StreamsBuilderFactoryBean; @@ -34,47 +34,44 @@ import org.springframework.kafka.core.DefaultKafkaProducerFactory; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.test.EmbeddedKafkaBroker; -import org.springframework.kafka.test.rule.EmbeddedKafkaRule; +import org.springframework.kafka.test.context.EmbeddedKafka; import org.springframework.kafka.test.utils.KafkaTestUtils; -import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; -@RunWith(SpringRunner.class) +@EmbeddedKafka(topics = {"words", "counts"}, count = 1, + bootstrapServersProperty = "spring.cloud.stream.kafka.streams.binder.brokers") @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.NONE, properties = {"server.port=0"}) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class KafkaStreamsWordCountApplicationTests { - @ClassRule - public static EmbeddedKafkaRule embeddedKafkaRule = new EmbeddedKafkaRule(1, true, "words", "counts"); - - private static EmbeddedKafkaBroker embeddedKafka = embeddedKafkaRule.getEmbeddedKafka(); + @Autowired + EmbeddedKafkaBroker embeddedKafka; - private static Consumer consumer; + private Consumer consumer; @Autowired StreamsBuilderFactoryBean streamsBuilderFactoryBean; - @Before + @BeforeEach public void before() { streamsBuilderFactoryBean.setCloseTimeout(0); } - @BeforeClass - public static void setUp() { + @BeforeAll + void setUp() { Map consumerProps = KafkaTestUtils.consumerProps("group", "false", embeddedKafka); consumerProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); DefaultKafkaConsumerFactory cf = new DefaultKafkaConsumerFactory<>(consumerProps); consumer = cf.createConsumer(); embeddedKafka.consumeFromAnEmbeddedTopic(consumer, "counts"); - System.setProperty("spring.cloud.stream.kafka.streams.binder.brokers", embeddedKafka.getBrokersAsString()); } - @AfterClass - public static void tearDown() { + @AfterAll + void tearDown() { consumer.close(); - System.clearProperty("spring.cloud.stream.kafka.streams.binder.brokers"); } @Test diff --git a/kafka-streams-samples/kafka-streams-word-count/src/test/java/kafka/streams/word/count/WordCountProcessorApplicationTests.java b/kafka-streams-samples/kafka-streams-word-count/src/test/java/kafka/streams/word/count/WordCountProcessorApplicationTests.java index aa5fa679..3b0e1c0c 100644 --- a/kafka-streams-samples/kafka-streams-word-count/src/test/java/kafka/streams/word/count/WordCountProcessorApplicationTests.java +++ b/kafka-streams-samples/kafka-streams-word-count/src/test/java/kafka/streams/word/count/WordCountProcessorApplicationTests.java @@ -28,9 +28,9 @@ import org.apache.kafka.streams.kstream.Consumed; import org.apache.kafka.streams.kstream.KStream; import org.apache.kafka.streams.kstream.Produced; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.kafka.support.serializer.JsonSerde; import java.time.Duration; @@ -73,7 +73,7 @@ static Properties getStreamsConfiguration() { * Add KStream based on @StreamListener annotation * Add to(topic) based @SendTo annotation */ - @Before + @BeforeEach public void setup() { final StreamsBuilder builder = new StreamsBuilder(); buildStreamProcessingPipeline(builder); @@ -91,7 +91,7 @@ private void buildStreamProcessingPipeline(StreamsBuilder builder) { output.to(OUTPUT_TOPIC, Produced.with(nullSerde, countSerde)); } - @After + @AfterEach public void tearDown() { try { testDriver.close(); diff --git a/kafka-streams-samples/pom.xml b/kafka-streams-samples/pom.xml index 4d29633f..b17d286a 100644 --- a/kafka-streams-samples/pom.xml +++ b/kafka-streams-samples/pom.xml @@ -1,6 +1,12 @@ 4.0.0 + + io.spring.cloud.stream.sample + spring-cloud-stream-samples-parent + 0.0.1-SNAPSHOT + .. + io.spring.cloud.stream.sample kafka-streams-samples 0.0.1-SNAPSHOT @@ -28,4 +34,11 @@ kafka-streams-interactive-query + + + com.fasterxml.jackson.core + jackson-databind + + + diff --git a/kinesis-samples/kinesis-produce-consume/pom.xml b/kinesis-samples/kinesis-produce-consume/pom.xml index d8d76411..9e0f49fc 100644 --- a/kinesis-samples/kinesis-produce-consume/pom.xml +++ b/kinesis-samples/kinesis-produce-consume/pom.xml @@ -11,33 +11,17 @@ - org.springframework.boot - spring-boot-starter-parent - 2.7.6 - + io.spring.cloud.stream.sample + kinesis-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud spring-cloud-stream-binder-kinesis - 2.2.0 + 4.0.0 @@ -71,63 +55,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/kinesis-samples/kinesis-produce-consume/src/main/java/demo/data/Order.java b/kinesis-samples/kinesis-produce-consume/src/main/java/demo/data/Order.java index 2ed16f96..544f5eec 100644 --- a/kinesis-samples/kinesis-produce-consume/src/main/java/demo/data/Order.java +++ b/kinesis-samples/kinesis-produce-consume/src/main/java/demo/data/Order.java @@ -18,10 +18,10 @@ import java.util.UUID; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; /** diff --git a/kinesis-samples/kinesis-produce-consume/src/main/java/demo/security/SecurityConfiguration.java b/kinesis-samples/kinesis-produce-consume/src/main/java/demo/security/SecurityConfiguration.java index 2f2bcbcc..29e0dcaf 100644 --- a/kinesis-samples/kinesis-produce-consume/src/main/java/demo/security/SecurityConfiguration.java +++ b/kinesis-samples/kinesis-produce-consume/src/main/java/demo/security/SecurityConfiguration.java @@ -3,6 +3,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.web.SecurityFilterChain; @Configuration @@ -10,6 +11,8 @@ public class SecurityConfiguration { @Bean public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { - return httpSecurity.csrf().disable().build(); + return httpSecurity + .csrf(AbstractHttpConfigurer::disable) + .build(); } } \ No newline at end of file diff --git a/kinesis-samples/kinesis-produce-consume/src/main/java/demo/stream/OrderStreamConfiguration.java b/kinesis-samples/kinesis-produce-consume/src/main/java/demo/stream/OrderStreamConfiguration.java index a6708ad6..7d1f1caa 100644 --- a/kinesis-samples/kinesis-produce-consume/src/main/java/demo/stream/OrderStreamConfiguration.java +++ b/kinesis-samples/kinesis-produce-consume/src/main/java/demo/stream/OrderStreamConfiguration.java @@ -22,13 +22,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.annotation.StreamListener; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import demo.repository.OrderRepository; -import org.springframework.stereotype.Component; /** * @@ -36,7 +33,7 @@ * @author Artem Bilan * */ -@Component +@Configuration public class OrderStreamConfiguration { private final Log logger = LogFactory.getLog(getClass()); diff --git a/kinesis-samples/kinesis-to-webflux/pom.xml b/kinesis-samples/kinesis-to-webflux/pom.xml index c0da43dd..7b3530d2 100644 --- a/kinesis-samples/kinesis-to-webflux/pom.xml +++ b/kinesis-samples/kinesis-to-webflux/pom.xml @@ -12,28 +12,12 @@ Spring Cloud Stream Kinesis to WebFlux Sample - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kinesis-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.boot @@ -47,17 +31,17 @@ org.springframework.boot - spring-boot-starter-test + spring-boot-starter-webflux-test test - io.projectreactor - reactor-test + org.springframework.boot + spring-boot-starter-test test - org.junit.vintage - junit-vintage-engine + io.projectreactor + reactor-test test @@ -71,63 +55,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/kinesis-samples/kinesis-to-webflux/src/test/java/kinesis/webflux/CloudStreamKinesisToWebfluxApplicationTests.java b/kinesis-samples/kinesis-to-webflux/src/test/java/kinesis/webflux/CloudStreamKinesisToWebfluxApplicationTests.java index ea7d2730..63a6df4d 100644 --- a/kinesis-samples/kinesis-to-webflux/src/test/java/kinesis/webflux/CloudStreamKinesisToWebfluxApplicationTests.java +++ b/kinesis-samples/kinesis-to-webflux/src/test/java/kinesis/webflux/CloudStreamKinesisToWebfluxApplicationTests.java @@ -28,7 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; +import org.springframework.boot.webtestclient.autoconfigure.AutoConfigureWebTestClient; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.cloud.aws.autoconfigure.context.ContextResourceLoaderAutoConfiguration; diff --git a/kinesis-samples/pom.xml b/kinesis-samples/pom.xml index c488a1b3..c15d82d2 100644 --- a/kinesis-samples/pom.xml +++ b/kinesis-samples/pom.xml @@ -1,6 +1,12 @@ 4.0.0 + + io.spring.cloud.stream.sample + spring-cloud-stream-samples-parent + 0.0.1-SNAPSHOT + .. + io.spring.cloud.stream.sample kinesis-samples 0.0.1-SNAPSHOT diff --git a/kotlin-rabbit-functions/pom.xml b/kotlin-rabbit-functions/pom.xml index 62fab906..33356d64 100644 --- a/kotlin-rabbit-functions/pom.xml +++ b/kotlin-rabbit-functions/pom.xml @@ -3,22 +3,16 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.6.1 - + io.spring.cloud.stream.sample + spring-cloud-stream-samples-parent + 0.0.1-SNAPSHOT + .. com.example kotlin-rabbit-functions 0.0.1-SNAPSHOT demo-kotlin Project to demonstrate Kotlin usage/configuration in spring-cloud-stream - - 1.8 - 1.6.0 - 2021.0.0 - - org.springframework.boot @@ -30,7 +24,7 @@ org.jetbrains.kotlin - kotlin-stdlib-jdk8 + kotlin-stdlib org.springframework.cloud @@ -39,7 +33,6 @@ org.springframework.cloud spring-cloud-function-context - 3.2.3 org.springframework.boot @@ -47,18 +40,6 @@ test - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - ${project.basedir}/src/main/kotlin ${project.basedir}/src/test/kotlin diff --git a/kotlin-rabbit-functions/src/main/kotlin/com/example/demokotlin/DemoKotlinConfiguration.kt b/kotlin-rabbit-functions/src/main/kotlin/com/example/demokotlin/DemoKotlinConfiguration.kt index 549eb390..b80deac6 100644 --- a/kotlin-rabbit-functions/src/main/kotlin/com/example/demokotlin/DemoKotlinConfiguration.kt +++ b/kotlin-rabbit-functions/src/main/kotlin/com/example/demokotlin/DemoKotlinConfiguration.kt @@ -10,7 +10,7 @@ import org.springframework.context.annotation.Configuration open class DemoKotlinConfiguration { @Bean open fun uppercase(): (String) -> String { - return { it.toUpperCase() } + return { it.uppercase() } } @Bean diff --git a/multi-binder-samples/kafka-multi-binder-jaas/pom.xml b/multi-binder-samples/kafka-multi-binder-jaas/pom.xml index 6a4833b8..d53b715b 100644 --- a/multi-binder-samples/kafka-multi-binder-jaas/pom.xml +++ b/multi-binder-samples/kafka-multi-binder-jaas/pom.xml @@ -11,28 +11,12 @@ Demo project with multi kafka cluster/binder with JAAS - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + multi-binder-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -58,7 +42,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -71,55 +55,4 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - - diff --git a/multi-binder-samples/multi-binder-dynamic-destinations/pom.xml b/multi-binder-samples/multi-binder-dynamic-destinations/pom.xml index 1e9f7c8f..72ce3ea2 100644 --- a/multi-binder-samples/multi-binder-dynamic-destinations/pom.xml +++ b/multi-binder-samples/multi-binder-dynamic-destinations/pom.xml @@ -9,33 +9,16 @@ Spring Cloud Stream Multibinder with Dynamic Destination - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + multi-binder-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud spring-cloud-function-context - 3.0.7.RELEASE org.springframework.cloud @@ -61,7 +44,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -74,55 +57,4 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - - diff --git a/multi-binder-samples/multi-binder-kafka-rabbit/pom.xml b/multi-binder-samples/multi-binder-kafka-rabbit/pom.xml index 82d8334a..0521856e 100644 --- a/multi-binder-samples/multi-binder-kafka-rabbit/pom.xml +++ b/multi-binder-samples/multi-binder-kafka-rabbit/pom.xml @@ -9,28 +9,12 @@ Spring Cloud Stream Multibinder Sample - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + multi-binder-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -60,7 +44,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -73,54 +57,4 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/multi-binder-samples/multi-binder-kafka-streams/pom.xml b/multi-binder-samples/multi-binder-kafka-streams/pom.xml index 0e7f300b..d3b15bcd 100644 --- a/multi-binder-samples/multi-binder-kafka-streams/pom.xml +++ b/multi-binder-samples/multi-binder-kafka-streams/pom.xml @@ -9,28 +9,12 @@ Spring Cloud Stream Multibinder Two Kafka Clusters (Kafka Streams) Sample - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + multi-binder-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -60,12 +44,7 @@ org.springframework.boot - spring-boot-starter-web - - - org.junit.vintage - junit-vintage-engine - test + spring-boot-starter-webmvc @@ -78,55 +57,4 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - - diff --git a/multi-binder-samples/multi-binder-kafka-streams/src/main/resources/application.yml b/multi-binder-samples/multi-binder-kafka-streams/src/main/resources/application.yml index 909c1c60..3d115db5 100644 --- a/multi-binder-samples/multi-binder-kafka-streams/src/main/resources/application.yml +++ b/multi-binder-samples/multi-binder-kafka-streams/src/main/resources/application.yml @@ -1,8 +1,8 @@ spring: cloud: + function: + definition: sendTestData;process;receive;concatFn stream: - function: - definition: sendTestData;process;receive;concatFn bindings: process-in-0: destination: dataIn diff --git a/multi-binder-samples/multi-binder-kafka-streams/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java b/multi-binder-samples/multi-binder-kafka-streams/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java index c419d6ad..ca549de4 100644 --- a/multi-binder-samples/multi-binder-kafka-streams/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java +++ b/multi-binder-samples/multi-binder-kafka-streams/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java @@ -18,14 +18,8 @@ import java.util.UUID; -import org.hamcrest.CoreMatchers; -import org.hamcrest.Matchers; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.annotation.Autowired; @@ -37,33 +31,41 @@ import org.springframework.cloud.stream.binder.kafka.properties.KafkaBinderConfigurationProperties; import org.springframework.cloud.stream.binder.kafka.properties.KafkaConsumerProperties; import org.springframework.integration.channel.QueueChannel; -import org.springframework.kafka.test.rule.EmbeddedKafkaRule; +import org.springframework.kafka.test.EmbeddedKafkaBroker; +import org.springframework.kafka.test.EmbeddedKafkaKraftBroker; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; -import static org.hamcrest.Matchers.arrayWithSize; -import static org.hamcrest.Matchers.equalTo; +import static org.assertj.core.api.Assertions.assertThat; -@RunWith(SpringRunner.class) @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.NONE) @DirtiesContext public class TwoKafkaBindersApplicationTest { - @ClassRule - public static EmbeddedKafkaRule kafkaTestSupport1 = new EmbeddedKafkaRule(1, true, "input", "output"); - - @ClassRule - public static EmbeddedKafkaRule kafkaTestSupport2 = new EmbeddedKafkaRule(1, true, "input", "output"); + private static final EmbeddedKafkaBroker kafkaTestSupport1; + private static final EmbeddedKafkaBroker kafkaTestSupport2; + static { + kafkaTestSupport1 = new EmbeddedKafkaKraftBroker(1, 1, "input", "output"); + kafkaTestSupport1.afterPropertiesSet(); + kafkaTestSupport2 = new EmbeddedKafkaKraftBroker(1, 1, "input", "output"); + kafkaTestSupport2.afterPropertiesSet(); + } + @DynamicPropertySource + static void kafkaProperties(DynamicPropertyRegistry registry) { + registry.add("kafkaBroker1", kafkaTestSupport1::getBrokersAsString); + registry.add("kafkaBroker2", kafkaTestSupport2::getBrokersAsString); + } - @BeforeClass - public static void setupEnvironment() { - System.setProperty("kafkaBroker1", kafkaTestSupport1.getEmbeddedKafka().getBrokersAsString()); - System.setProperty("kafkaBroker2", kafkaTestSupport2.getEmbeddedKafka().getBrokersAsString()); + @AfterAll + static void tearDown() { + kafkaTestSupport1.destroy(); + kafkaTestSupport2.destroy(); } @Autowired @@ -76,16 +78,16 @@ public void contextLoads() { DirectFieldAccessor directFieldAccessor1 = new DirectFieldAccessor(kafka1); KafkaBinderConfigurationProperties configuration1 = (KafkaBinderConfigurationProperties) directFieldAccessor1.getPropertyValue("configurationProperties"); - Assert.assertThat(configuration1.getBrokers(), arrayWithSize(1)); - Assert.assertThat(configuration1.getBrokers()[0], equalTo(kafkaTestSupport1.getEmbeddedKafka().getBrokersAsString())); + assertThat(configuration1.getBrokers()).hasSize(1); + assertThat(configuration1.getBrokers()[0]).isEqualTo(kafkaTestSupport1.getBrokersAsString()); Binder binder2 = binderFactory.getBinder("kafka2", MessageChannel.class); KafkaMessageChannelBinder kafka2 = (KafkaMessageChannelBinder) binder2; DirectFieldAccessor directFieldAccessor2 = new DirectFieldAccessor(kafka2); KafkaBinderConfigurationProperties configuration2 = (KafkaBinderConfigurationProperties) directFieldAccessor2.getPropertyValue("configurationProperties"); - Assert.assertThat(configuration2.getBrokers(), arrayWithSize(1)); - Assert.assertThat(configuration2.getBrokers()[0], equalTo(kafkaTestSupport2.getEmbeddedKafka().getBrokersAsString())); + assertThat(configuration2.getBrokers()).hasSize(1); + assertThat(configuration2.getBrokers()[0]).isEqualTo(kafkaTestSupport2.getBrokersAsString()); } @Test @@ -96,8 +98,8 @@ public void messagingWorks() { //receiving test message sent by the test producer in the application Message receive = dataConsumer.receive(60_000); - Assert.assertThat(receive, Matchers.notNullValue()); - Assert.assertThat(receive.getPayload(), CoreMatchers.anyOf(equalTo("FOO".getBytes()), equalTo("BAR".getBytes()))); + assertThat(receive).isNotNull(); + assertThat(receive.getPayload()).isIn("FOO".getBytes(), "BAR".getBytes()); } } diff --git a/multi-binder-samples/multi-binder-sendto-dest-header/pom.xml b/multi-binder-samples/multi-binder-sendto-dest-header/pom.xml index 8cd63adc..cea64ee1 100644 --- a/multi-binder-samples/multi-binder-sendto-dest-header/pom.xml +++ b/multi-binder-samples/multi-binder-sendto-dest-header/pom.xml @@ -9,28 +9,12 @@ Spring Cloud Stream Multibinder Two Kafka Clusters Sample with sendto header - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + multi-binder-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -56,12 +40,7 @@ org.springframework.boot - spring-boot-starter-web - - - org.junit.vintage - junit-vintage-engine - test + spring-boot-starter-webmvc @@ -74,55 +53,4 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - - diff --git a/multi-binder-samples/multi-binder-sendto-dest-header/src/main/resources/application.yml b/multi-binder-samples/multi-binder-sendto-dest-header/src/main/resources/application.yml index 8764c147..b2c8cbfd 100644 --- a/multi-binder-samples/multi-binder-sendto-dest-header/src/main/resources/application.yml +++ b/multi-binder-samples/multi-binder-sendto-dest-header/src/main/resources/application.yml @@ -1,5 +1,7 @@ spring: cloud: + function: + definition: sendTestData;process;receive stream: default-binder: kafka2 bindings: @@ -14,8 +16,6 @@ spring: receive-in-0: destination: dataOut binder: kafka2 - function: - definition: sendTestData;process;receive binders: kafka1: type: kafka diff --git a/multi-binder-samples/multi-binder-sendto-dest-header/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java b/multi-binder-samples/multi-binder-sendto-dest-header/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java index e1fd1fcb..fad1d16f 100644 --- a/multi-binder-samples/multi-binder-sendto-dest-header/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java +++ b/multi-binder-samples/multi-binder-sendto-dest-header/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java @@ -16,13 +16,10 @@ package multibinder; -import org.hamcrest.CoreMatchers; -import org.hamcrest.Matchers; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import java.util.UUID; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.annotation.Autowired; @@ -34,34 +31,43 @@ import org.springframework.cloud.stream.binder.kafka.properties.KafkaBinderConfigurationProperties; import org.springframework.cloud.stream.binder.kafka.properties.KafkaConsumerProperties; import org.springframework.integration.channel.QueueChannel; -import org.springframework.kafka.test.rule.EmbeddedKafkaRule; +import org.springframework.kafka.test.EmbeddedKafkaBroker; +import org.springframework.kafka.test.EmbeddedKafkaKraftBroker; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; - -import java.util.UUID; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; -import static org.hamcrest.Matchers.arrayWithSize; -import static org.hamcrest.Matchers.equalTo; +import static org.assertj.core.api.Assertions.assertThat; -@RunWith(SpringRunner.class) @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.NONE) @DirtiesContext public class TwoKafkaBindersApplicationTest { - @ClassRule - public static EmbeddedKafkaRule kafkaTestSupport1 = new EmbeddedKafkaRule(1, true, "input", "output"); + private static final EmbeddedKafkaBroker kafkaTestSupport1; + private static final EmbeddedKafkaBroker kafkaTestSupport2; - @ClassRule - public static EmbeddedKafkaRule kafkaTestSupport2 = new EmbeddedKafkaRule(1, true, "input", "output"); + static { + kafkaTestSupport1 = new EmbeddedKafkaKraftBroker(1, 1, "input", "output"); + kafkaTestSupport1.afterPropertiesSet(); + kafkaTestSupport2 = new EmbeddedKafkaKraftBroker(1, 1, "input", "output"); + kafkaTestSupport2.afterPropertiesSet(); + } + @DynamicPropertySource + static void kafkaProperties(DynamicPropertyRegistry registry) { + registry.add("kafkaBroker1", kafkaTestSupport1::getBrokersAsString); + registry.add("kafkaBroker2", kafkaTestSupport2::getBrokersAsString); + registry.add("zk1", () -> "localhost"); + registry.add("zk2", () -> "localhost"); + } - @BeforeClass - public static void setupEnvironment() { - System.setProperty("kafkaBroker1", kafkaTestSupport1.getEmbeddedKafka().getBrokersAsString()); - System.setProperty("kafkaBroker2", kafkaTestSupport2.getEmbeddedKafka().getBrokersAsString()); + @AfterAll + static void tearDown() { + kafkaTestSupport1.destroy(); + kafkaTestSupport2.destroy(); } @Autowired @@ -74,16 +80,16 @@ public void contextLoads() { DirectFieldAccessor directFieldAccessor1 = new DirectFieldAccessor(kafka1); KafkaBinderConfigurationProperties configuration1 = (KafkaBinderConfigurationProperties) directFieldAccessor1.getPropertyValue("configurationProperties"); - Assert.assertThat(configuration1.getBrokers(), arrayWithSize(1)); - Assert.assertThat(configuration1.getBrokers()[0], equalTo(kafkaTestSupport1.getEmbeddedKafka().getBrokersAsString())); + assertThat(configuration1.getBrokers()).hasSize(1); + assertThat(configuration1.getBrokers()[0]).isEqualTo(kafkaTestSupport1.getBrokersAsString()); Binder binder2 = binderFactory.getBinder("kafka2", MessageChannel.class); KafkaMessageChannelBinder kafka2 = (KafkaMessageChannelBinder) binder2; DirectFieldAccessor directFieldAccessor2 = new DirectFieldAccessor(kafka2); KafkaBinderConfigurationProperties configuration2 = (KafkaBinderConfigurationProperties) directFieldAccessor2.getPropertyValue("configurationProperties"); - Assert.assertThat(configuration2.getBrokers(), arrayWithSize(1)); - Assert.assertThat(configuration2.getBrokers()[0], equalTo(kafkaTestSupport2.getEmbeddedKafka().getBrokersAsString())); + assertThat(configuration2.getBrokers()).hasSize(1); + assertThat(configuration2.getBrokers()[0]).isEqualTo(kafkaTestSupport2.getBrokersAsString()); } @Test @@ -94,8 +100,8 @@ public void messagingWorks() { //receiving test message sent by the test producer in the application Message receive = dataConsumer.receive(60_000); - Assert.assertThat(receive, Matchers.notNullValue()); - Assert.assertThat(receive.getPayload(), CoreMatchers.anyOf(equalTo("FOO".getBytes()), equalTo("BAR".getBytes()))); + assertThat(receive).isNotNull(); + assertThat(receive.getPayload()).isIn("FOO".getBytes(), "BAR".getBytes()); } } diff --git a/multi-binder-samples/multi-binder-two-kafka-clusters/pom.xml b/multi-binder-samples/multi-binder-two-kafka-clusters/pom.xml index 320b9f40..e4599c75 100644 --- a/multi-binder-samples/multi-binder-two-kafka-clusters/pom.xml +++ b/multi-binder-samples/multi-binder-two-kafka-clusters/pom.xml @@ -9,28 +9,12 @@ Spring Cloud Stream Multibinder Two Kafka Clusters Sample - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + multi-binder-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -56,12 +40,7 @@ org.springframework.boot - spring-boot-starter-web - - - org.junit.vintage - junit-vintage-engine - test + spring-boot-starter-webmvc @@ -74,55 +53,4 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - - diff --git a/multi-binder-samples/multi-binder-two-kafka-clusters/src/main/resources/application.yml b/multi-binder-samples/multi-binder-two-kafka-clusters/src/main/resources/application.yml index 4392fbdc..c85049e8 100644 --- a/multi-binder-samples/multi-binder-two-kafka-clusters/src/main/resources/application.yml +++ b/multi-binder-samples/multi-binder-two-kafka-clusters/src/main/resources/application.yml @@ -1,5 +1,7 @@ spring: cloud: + function: + definition: sendTestData;process;receive stream: default-binder: kafka2 bindings: @@ -17,8 +19,6 @@ spring: receive-in-0: destination: dataOut binder: kafka2 - function: - definition: sendTestData;process;receive binders: kafka1: type: kafka diff --git a/multi-binder-samples/multi-binder-two-kafka-clusters/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java b/multi-binder-samples/multi-binder-two-kafka-clusters/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java index e1fd1fcb..fad1d16f 100644 --- a/multi-binder-samples/multi-binder-two-kafka-clusters/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java +++ b/multi-binder-samples/multi-binder-two-kafka-clusters/src/test/java/multibinder/TwoKafkaBindersApplicationTest.java @@ -16,13 +16,10 @@ package multibinder; -import org.hamcrest.CoreMatchers; -import org.hamcrest.Matchers; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import java.util.UUID; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.annotation.Autowired; @@ -34,34 +31,43 @@ import org.springframework.cloud.stream.binder.kafka.properties.KafkaBinderConfigurationProperties; import org.springframework.cloud.stream.binder.kafka.properties.KafkaConsumerProperties; import org.springframework.integration.channel.QueueChannel; -import org.springframework.kafka.test.rule.EmbeddedKafkaRule; +import org.springframework.kafka.test.EmbeddedKafkaBroker; +import org.springframework.kafka.test.EmbeddedKafkaKraftBroker; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; - -import java.util.UUID; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; -import static org.hamcrest.Matchers.arrayWithSize; -import static org.hamcrest.Matchers.equalTo; +import static org.assertj.core.api.Assertions.assertThat; -@RunWith(SpringRunner.class) @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.NONE) @DirtiesContext public class TwoKafkaBindersApplicationTest { - @ClassRule - public static EmbeddedKafkaRule kafkaTestSupport1 = new EmbeddedKafkaRule(1, true, "input", "output"); + private static final EmbeddedKafkaBroker kafkaTestSupport1; + private static final EmbeddedKafkaBroker kafkaTestSupport2; - @ClassRule - public static EmbeddedKafkaRule kafkaTestSupport2 = new EmbeddedKafkaRule(1, true, "input", "output"); + static { + kafkaTestSupport1 = new EmbeddedKafkaKraftBroker(1, 1, "input", "output"); + kafkaTestSupport1.afterPropertiesSet(); + kafkaTestSupport2 = new EmbeddedKafkaKraftBroker(1, 1, "input", "output"); + kafkaTestSupport2.afterPropertiesSet(); + } + @DynamicPropertySource + static void kafkaProperties(DynamicPropertyRegistry registry) { + registry.add("kafkaBroker1", kafkaTestSupport1::getBrokersAsString); + registry.add("kafkaBroker2", kafkaTestSupport2::getBrokersAsString); + registry.add("zk1", () -> "localhost"); + registry.add("zk2", () -> "localhost"); + } - @BeforeClass - public static void setupEnvironment() { - System.setProperty("kafkaBroker1", kafkaTestSupport1.getEmbeddedKafka().getBrokersAsString()); - System.setProperty("kafkaBroker2", kafkaTestSupport2.getEmbeddedKafka().getBrokersAsString()); + @AfterAll + static void tearDown() { + kafkaTestSupport1.destroy(); + kafkaTestSupport2.destroy(); } @Autowired @@ -74,16 +80,16 @@ public void contextLoads() { DirectFieldAccessor directFieldAccessor1 = new DirectFieldAccessor(kafka1); KafkaBinderConfigurationProperties configuration1 = (KafkaBinderConfigurationProperties) directFieldAccessor1.getPropertyValue("configurationProperties"); - Assert.assertThat(configuration1.getBrokers(), arrayWithSize(1)); - Assert.assertThat(configuration1.getBrokers()[0], equalTo(kafkaTestSupport1.getEmbeddedKafka().getBrokersAsString())); + assertThat(configuration1.getBrokers()).hasSize(1); + assertThat(configuration1.getBrokers()[0]).isEqualTo(kafkaTestSupport1.getBrokersAsString()); Binder binder2 = binderFactory.getBinder("kafka2", MessageChannel.class); KafkaMessageChannelBinder kafka2 = (KafkaMessageChannelBinder) binder2; DirectFieldAccessor directFieldAccessor2 = new DirectFieldAccessor(kafka2); KafkaBinderConfigurationProperties configuration2 = (KafkaBinderConfigurationProperties) directFieldAccessor2.getPropertyValue("configurationProperties"); - Assert.assertThat(configuration2.getBrokers(), arrayWithSize(1)); - Assert.assertThat(configuration2.getBrokers()[0], equalTo(kafkaTestSupport2.getEmbeddedKafka().getBrokersAsString())); + assertThat(configuration2.getBrokers()).hasSize(1); + assertThat(configuration2.getBrokers()[0]).isEqualTo(kafkaTestSupport2.getBrokersAsString()); } @Test @@ -94,8 +100,8 @@ public void messagingWorks() { //receiving test message sent by the test producer in the application Message receive = dataConsumer.receive(60_000); - Assert.assertThat(receive, Matchers.notNullValue()); - Assert.assertThat(receive.getPayload(), CoreMatchers.anyOf(equalTo("FOO".getBytes()), equalTo("BAR".getBytes()))); + assertThat(receive).isNotNull(); + assertThat(receive.getPayload()).isIn("FOO".getBytes(), "BAR".getBytes()); } } diff --git a/multi-binder-samples/pom.xml b/multi-binder-samples/pom.xml index 6f7d2bf1..b34f5124 100644 --- a/multi-binder-samples/pom.xml +++ b/multi-binder-samples/pom.xml @@ -1,6 +1,12 @@ 4.0.0 + + io.spring.cloud.stream.sample + spring-cloud-stream-samples-parent + 0.0.1-SNAPSHOT + .. + io.spring.cloud.stream.sample multi-binder-samples 0.0.1-SNAPSHOT diff --git a/multi-functions-samples/function-composition-kafka/pom.xml b/multi-functions-samples/function-composition-kafka/pom.xml index 72ac9238..668296be 100644 --- a/multi-functions-samples/function-composition-kafka/pom.xml +++ b/multi-functions-samples/function-composition-kafka/pom.xml @@ -9,28 +9,12 @@ Spring Cloud Stream Sample Function Composition Kafka - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + multi-functions-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -56,7 +40,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -69,55 +53,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/multi-functions-samples/function-composition-rabbit/pom.xml b/multi-functions-samples/function-composition-rabbit/pom.xml index 199c613f..8a406dc2 100644 --- a/multi-functions-samples/function-composition-rabbit/pom.xml +++ b/multi-functions-samples/function-composition-rabbit/pom.xml @@ -9,28 +9,12 @@ Spring Cloud Stream Sample Function Composition Rabbit - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + multi-functions-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -51,7 +35,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -64,55 +48,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/multi-functions-samples/multi-functions-kafka/pom.xml b/multi-functions-samples/multi-functions-kafka/pom.xml index fea053eb..35689b4e 100644 --- a/multi-functions-samples/multi-functions-kafka/pom.xml +++ b/multi-functions-samples/multi-functions-kafka/pom.xml @@ -9,28 +9,12 @@ Spring Cloud Stream Sample Multiple functions Kafka - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + multi-functions-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -56,7 +40,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -69,55 +53,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/multi-functions-samples/multi-functions-rabbit/pom.xml b/multi-functions-samples/multi-functions-rabbit/pom.xml index 195a0274..e6b847ab 100644 --- a/multi-functions-samples/multi-functions-rabbit/pom.xml +++ b/multi-functions-samples/multi-functions-rabbit/pom.xml @@ -9,28 +9,12 @@ Spring Cloud Stream Sample Multiple functions Rabbit - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + multi-functions-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -51,7 +35,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -64,55 +48,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/multi-functions-samples/pom.xml b/multi-functions-samples/pom.xml index d8fb1cc8..fab9bcce 100644 --- a/multi-functions-samples/pom.xml +++ b/multi-functions-samples/pom.xml @@ -1,6 +1,12 @@ 4.0.0 + + io.spring.cloud.stream.sample + spring-cloud-stream-samples-parent + 0.0.1-SNAPSHOT + .. + io.spring.cloud.stream.sample multi-functions-samples 0.0.1-SNAPSHOT diff --git a/partitioning-samples/kafka-partitioning/partitioning-consumer-sample-kafka/pom.xml b/partitioning-samples/kafka-partitioning/partitioning-consumer-sample-kafka/pom.xml index a810f3aa..6fe27e8d 100644 --- a/partitioning-samples/kafka-partitioning/partitioning-consumer-sample-kafka/pom.xml +++ b/partitioning-samples/kafka-partitioning/partitioning-consumer-sample-kafka/pom.xml @@ -9,28 +9,12 @@ Spring Cloud Stream Partitioning producer Kafka - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-partitioning + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -56,7 +40,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -69,54 +53,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - + diff --git a/partitioning-samples/kafka-partitioning/partitioning-consumer-sample-kafka/src/main/java/demo/PartitioningKafkaDemoApplication.java b/partitioning-samples/kafka-partitioning/partitioning-consumer-sample-kafka/src/main/java/demo/PartitioningKafkaDemoApplication.java index a6805b6e..3a7ebf60 100644 --- a/partitioning-samples/kafka-partitioning/partitioning-consumer-sample-kafka/src/main/java/demo/PartitioningKafkaDemoApplication.java +++ b/partitioning-samples/kafka-partitioning/partitioning-consumer-sample-kafka/src/main/java/demo/PartitioningKafkaDemoApplication.java @@ -38,6 +38,6 @@ public static void main(String[] args) { @Bean public Consumer> listen() { return message -> logger.info(message.getPayload() + " received from partition " - + message.getHeaders().get(KafkaHeaders.RECEIVED_PARTITION_ID)); + + message.getHeaders().get(KafkaHeaders.RECEIVED_PARTITION)); } } diff --git a/partitioning-samples/kafka-partitioning/partitioning-producer-sample-kafka/pom.xml b/partitioning-samples/kafka-partitioning/partitioning-producer-sample-kafka/pom.xml index 96c52b89..a84cde3a 100644 --- a/partitioning-samples/kafka-partitioning/partitioning-producer-sample-kafka/pom.xml +++ b/partitioning-samples/kafka-partitioning/partitioning-producer-sample-kafka/pom.xml @@ -9,28 +9,12 @@ Spring Cloud Stream Partitioning Kafka - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + kafka-partitioning + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -56,7 +40,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -69,54 +53,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - + diff --git a/partitioning-samples/kafka-partitioning/pom.xml b/partitioning-samples/kafka-partitioning/pom.xml index ddbf31af..e6f7ad2d 100644 --- a/partitioning-samples/kafka-partitioning/pom.xml +++ b/partitioning-samples/kafka-partitioning/pom.xml @@ -1,6 +1,12 @@ 4.0.0 + + io.spring.cloud.stream.sample + partitioning-samples + 0.0.1-SNAPSHOT + .. + io.spring.cloud.stream.sample kafka-partitioning 0.0.1-SNAPSHOT diff --git a/partitioning-samples/pom.xml b/partitioning-samples/pom.xml index 3e15c9a8..53cc9e03 100644 --- a/partitioning-samples/pom.xml +++ b/partitioning-samples/pom.xml @@ -1,6 +1,12 @@ 4.0.0 + + io.spring.cloud.stream.sample + spring-cloud-stream-samples-parent + 0.0.1-SNAPSHOT + .. + io.spring.cloud.stream.sample partitioning-samples 0.0.1-SNAPSHOT diff --git a/partitioning-samples/rabbit-partitioning/partitioning-consumer-sample-rabbit/pom.xml b/partitioning-samples/rabbit-partitioning/partitioning-consumer-sample-rabbit/pom.xml index cb2e4596..b3f2af6e 100644 --- a/partitioning-samples/rabbit-partitioning/partitioning-consumer-sample-rabbit/pom.xml +++ b/partitioning-samples/rabbit-partitioning/partitioning-consumer-sample-rabbit/pom.xml @@ -9,28 +9,12 @@ Spring Cloud Stream Partitioning Rabbit - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + rabbit-partitioning + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -51,7 +35,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -64,54 +48,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - + diff --git a/partitioning-samples/rabbit-partitioning/partitioning-producer-sample-rabbit/pom.xml b/partitioning-samples/rabbit-partitioning/partitioning-producer-sample-rabbit/pom.xml index eda5c04b..dbcf1f51 100644 --- a/partitioning-samples/rabbit-partitioning/partitioning-producer-sample-rabbit/pom.xml +++ b/partitioning-samples/rabbit-partitioning/partitioning-producer-sample-rabbit/pom.xml @@ -9,28 +9,12 @@ Spring Cloud Stream Partitioning producer rabbit - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + rabbit-partitioning + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -51,7 +35,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -64,54 +48,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - + diff --git a/partitioning-samples/rabbit-partitioning/pom.xml b/partitioning-samples/rabbit-partitioning/pom.xml index b43c2462..4ef427e1 100644 --- a/partitioning-samples/rabbit-partitioning/pom.xml +++ b/partitioning-samples/rabbit-partitioning/pom.xml @@ -1,6 +1,12 @@ 4.0.0 + + io.spring.cloud.stream.sample + partitioning-samples + 0.0.1-SNAPSHOT + .. + io.spring.cloud.stream.sample rabbit-partitioning 0.0.1-SNAPSHOT diff --git a/pom.xml b/pom.xml index d147b6fe..b3f82f9c 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 3.1.3 + 4.0.0 @@ -43,18 +43,18 @@ UTF-8 UTF-8 17 - 1.11.0 - 7.0.1 - 2023.0.0-SNAPSHOT - 4.0.3 + 1.12.0 + 7.9.0 + 2025.1.0 + 2.2.0 org.springframework.cloud - spring-cloud-stream-dependencies - ${spring-cloud-stream.version} + spring-cloud-dependencies + ${spring-cloud.version} pom import @@ -72,7 +72,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -104,7 +104,19 @@ false + + confluent + https://packages.confluent.io/maven/ + + + + + org.springframework.boot + spring-boot-maven-plugin + + + spring-snapshots diff --git a/routing-samples/message-routing-callback/pom.xml b/routing-samples/message-routing-callback/pom.xml index 1d44691e..8bc9ecb7 100644 --- a/routing-samples/message-routing-callback/pom.xml +++ b/routing-samples/message-routing-callback/pom.xml @@ -3,18 +3,15 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.5.2 - + io.spring.cloud.stream.sample + routing-samples + 0.0.1-SNAPSHOT + .. message-routing-callback 0.0.1-SNAPSHOT message-routing-callback Demo for spring cloud stream app that have many consumers pointing to to the same topic - - 2020.0.3 - org.springframework.cloud @@ -37,10 +34,8 @@ org.springframework.cloud - spring-cloud-stream + spring-cloud-stream-test-binder test - test-binder - test-jar org.springframework.kafka @@ -48,20 +43,20 @@ test - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - + + org.apache.maven.plugins + maven-compiler-plugin + + + + org.projectlombok + lombok + + + + org.springframework.boot spring-boot-maven-plugin diff --git a/routing-samples/message-routing-callback/src/main/java/demo/CustomMessageRoutingCallback.java b/routing-samples/message-routing-callback/src/main/java/demo/CustomMessageRoutingCallback.java index b76b4d3d..52363036 100644 --- a/routing-samples/message-routing-callback/src/main/java/demo/CustomMessageRoutingCallback.java +++ b/routing-samples/message-routing-callback/src/main/java/demo/CustomMessageRoutingCallback.java @@ -1,7 +1,6 @@ package demo; import org.springframework.cloud.function.context.MessageRoutingCallback; -import org.springframework.cloud.stream.annotation.StreamListener; import org.springframework.messaging.Message; import java.util.Arrays; @@ -9,14 +8,14 @@ /** * A custom implementation of {@link MessageRoutingCallback} that will route each message to its corresponding binding channel. - * This is the equivalence of {@link StreamListener#condition()} + * This is the functional equivalent of the legacy StreamListener condition-based routing. */ public class CustomMessageRoutingCallback implements MessageRoutingCallback { public static final String EVENT_TYPE = "event_type"; @Override - public String functionDefinition(Message message) { + public String routingResult(Message message) { return Optional.of(message.getHeaders()) .filter(headers -> headers.containsKey(EVENT_TYPE)) .map(messageHeaders -> messageHeaders.get(EVENT_TYPE)) diff --git a/routing-samples/pom.xml b/routing-samples/pom.xml index 395ca01a..bf9972ba 100644 --- a/routing-samples/pom.xml +++ b/routing-samples/pom.xml @@ -1,6 +1,12 @@ 4.0.0 + + io.spring.cloud.stream.sample + spring-cloud-stream-samples-parent + 0.0.1-SNAPSHOT + .. + io.spring.cloud.stream.sample routing-samples 0.0.1-SNAPSHOT diff --git a/spring-cloud-stream-schema-registry-integration/pom.xml b/spring-cloud-stream-schema-registry-integration/pom.xml index 8ebb8b6a..8ffbc54f 100644 --- a/spring-cloud-stream-schema-registry-integration/pom.xml +++ b/spring-cloud-stream-schema-registry-integration/pom.xml @@ -22,8 +22,6 @@ 1.11.3 - 7.0.1 - 2023.0.0-SNAPSHOT @@ -60,7 +58,11 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc + + + org.springframework.boot + spring-boot-restclient org.springframework.cloud @@ -92,68 +94,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - confluent - https://packages.confluent.io/maven/ - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/spring-cloud-stream-schema-registry-integration/schema-registry-consumer-kafka/src/test/java/sample/consumer/ConsumerApplicationTests.java b/spring-cloud-stream-schema-registry-integration/schema-registry-consumer-kafka/src/test/java/sample/consumer/ConsumerApplicationTests.java index c181396c..a53e3e9f 100644 --- a/spring-cloud-stream-schema-registry-integration/schema-registry-consumer-kafka/src/test/java/sample/consumer/ConsumerApplicationTests.java +++ b/spring-cloud-stream-schema-registry-integration/schema-registry-consumer-kafka/src/test/java/sample/consumer/ConsumerApplicationTests.java @@ -26,7 +26,12 @@ import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration; import org.springframework.cloud.stream.function.StreamBridge; +import org.springframework.cloud.stream.schema.registry.SchemaReference; +import org.springframework.cloud.stream.schema.registry.SchemaRegistrationResponse; +import org.springframework.cloud.stream.schema.registry.client.SchemaRegistryClient; import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.util.MimeType; import java.time.Duration; @@ -43,10 +48,13 @@ void test(CapturedOutput output) { try (ConfigurableApplicationContext context = new SpringApplicationBuilder( TestChannelBinderConfiguration - .getCompleteConfiguration(ConsumerApplication.class)) + .getCompleteConfiguration( + ConsumerApplication.class, + StubSchemaRegistryClientConfig.class)) .web(WebApplicationType.NONE) .run( - "--spring.cloud.schema.avro.ignore-schema-registry-server=true" + "--spring.cloud.stream.schema.avro.ignore-schema-registry-server=true", + "--spring.main.allow-bean-definition-overriding=true" ) ) { @@ -63,4 +71,31 @@ void test(CapturedOutput output) { .until(() -> output.toString().contains("[INPUT-RECEIVED]: {\"id\":")); } } + + @Configuration(proxyBeanMethods = false) + static class StubSchemaRegistryClientConfig { + + @Bean + SchemaRegistryClient schemaRegistryClient() { + return new SchemaRegistryClient() { + @Override + public SchemaRegistrationResponse register(String subject, String format, String schema) { + SchemaRegistrationResponse response = new SchemaRegistrationResponse(); + response.setId(1); + response.setSchemaReference(new SchemaReference(subject, 1, format)); + return response; + } + + @Override + public String fetch(SchemaReference schemaReference) { + return "{}"; + } + + @Override + public String fetch(int id) { + return "{}"; + } + }; + } + } } diff --git a/testing-samples/pom.xml b/testing-samples/pom.xml index 8173321f..924e3721 100644 --- a/testing-samples/pom.xml +++ b/testing-samples/pom.xml @@ -1,6 +1,12 @@ 4.0.0 + + io.spring.cloud.stream.sample + spring-cloud-stream-samples-parent + 0.0.1-SNAPSHOT + .. + io.spring.cloud.stream.sample testing-samples 0.0.1-SNAPSHOT diff --git a/testing-samples/test-embedded-kafka/pom.xml b/testing-samples/test-embedded-kafka/pom.xml index 6142acc1..b2c0e4d6 100644 --- a/testing-samples/test-embedded-kafka/pom.xml +++ b/testing-samples/test-embedded-kafka/pom.xml @@ -10,28 +10,12 @@ Spring Cloud Stream Sample for Testing with Embedded Kafka - org.springframework.boot - spring-boot-starter-parent - 2.4.10 - + io.spring.cloud.stream.sample + testing-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.3 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -57,7 +41,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -70,55 +54,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - diff --git a/testing-samples/testing-demo/pom.xml b/testing-samples/testing-demo/pom.xml index fc393985..3cb120be 100644 --- a/testing-samples/testing-demo/pom.xml +++ b/testing-samples/testing-demo/pom.xml @@ -10,28 +10,12 @@ Demonstrating how to test spring cloud stream apps - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + testing-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -49,12 +33,29 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc + + + + + org.springframework.boot + spring-boot-kafka + test + + + org.springframework.boot + spring-boot-jdbc + test + + + org.springframework.boot + spring-boot-transaction + test org.springframework.cloud - spring-cloud-stream-test-support + spring-cloud-stream-test-binder test @@ -75,12 +76,18 @@ spring-kafka-test test - - org.junit.vintage - junit-vintage-engine - test - - + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + diff --git a/testing-samples/testing-demo/src/main/java/org/springframework/cloud/stream/testing/sink/JdbcSink.java b/testing-samples/testing-demo/src/main/java/org/springframework/cloud/stream/testing/sink/JdbcSink.java index 1cec6021..5248c103 100644 --- a/testing-samples/testing-demo/src/main/java/org/springframework/cloud/stream/testing/sink/JdbcSink.java +++ b/testing-samples/testing-demo/src/main/java/org/springframework/cloud/stream/testing/sink/JdbcSink.java @@ -24,7 +24,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.jdbc.JdbcMessageHandler; import org.springframework.messaging.MessageHandler; @@ -40,7 +39,7 @@ public class JdbcSink { @Bean public IntegrationFlow jdbcConsumerFlow() { - return IntegrationFlows.from(Consumer.class, (gateway) -> gateway.beanName("jdbcConsumer")) + return IntegrationFlow.from(Consumer.class, (gateway) -> gateway.beanName("jdbcConsumer")) .handle(jdbcHandler(null)) .get(); } diff --git a/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/processor/NaiveToUpperCaseTests.java b/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/processor/NaiveToUpperCaseTests.java index e5437556..faf0cbb1 100644 --- a/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/processor/NaiveToUpperCaseTests.java +++ b/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/processor/NaiveToUpperCaseTests.java @@ -16,7 +16,7 @@ package org.springframework.cloud.stream.testing.processor; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; diff --git a/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/processor/ToUpperCaseProcessorTests.java b/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/processor/ToUpperCaseProcessorTests.java index 7c808159..88954045 100644 --- a/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/processor/ToUpperCaseProcessorTests.java +++ b/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/processor/ToUpperCaseProcessorTests.java @@ -16,36 +16,24 @@ package org.springframework.cloud.stream.testing.processor; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertThat; -import static org.springframework.cloud.stream.test.matcher.MessageQueueMatcher.receivesMessageThat; -import static org.springframework.cloud.stream.test.matcher.MessageQueueMatcher.receivesPayloadThat; -import static org.springframework.integration.test.matcher.PayloadAndHeaderMatcher.sameExceptIgnorableHeaders; +import static org.assertj.core.api.Assertions.assertThat; -import java.util.concurrent.BlockingQueue; - -import org.hamcrest.Matcher; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.actuate.autoconfigure.metrics.KafkaMetricsAutoConfiguration; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration; -import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration; +import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; +import org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration; +import org.springframework.boot.kafka.autoconfigure.KafkaAutoConfiguration; +import org.springframework.boot.kafka.autoconfigure.metrics.KafkaMetricsAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.stream.test.binder.MessageCollector; -import org.springframework.http.MediaType; -import org.springframework.integration.support.MessageBuilder; +import org.springframework.boot.transaction.autoconfigure.TransactionAutoConfiguration; +import org.springframework.cloud.stream.binder.test.InputDestination; +import org.springframework.cloud.stream.binder.test.OutputDestination; +import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration; import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.support.GenericMessage; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.util.MimeType; /** * The Spring Boot-base test-case to demonstrate how can we test Spring Cloud Stream applications @@ -54,7 +42,8 @@ * @author Artem Bilan * */ -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, + classes = { ToUpperCaseProcessor.class, TestChannelBinderConfiguration.class }) @ImportAutoConfiguration(exclude = { KafkaAutoConfiguration.class, KafkaMetricsAutoConfiguration.class, @@ -65,48 +54,37 @@ class ToUpperCaseProcessorTests { @Autowired - @Qualifier("uppercaseFunction-in-0") - private MessageChannel input; - - @Autowired - @Qualifier("uppercaseFunction-out-0") - private MessageChannel output; + private InputDestination input; @Autowired - private MessageCollector collector; + private OutputDestination output; @Test - @SuppressWarnings("unchecked") void testMessages() { this.input.send(new GenericMessage<>("odd")); - this.input.send(new GenericMessage<>("even")); - this.input.send(new GenericMessage<>("odd meets even")); - this.input.send(new GenericMessage<>("nothing but the best test")); - - BlockingQueue> messages = this.collector.forChannel(this.output); + Message result = this.output.receive(5000); + assertThat(result).isNotNull(); + assertThat(new String(result.getPayload())).isEqualTo("ODD"); - assertThat(messages, receivesPayloadThat(is("ODD"))); - assertThat(messages, receivesPayloadThat(is("EVEN"))); - assertThat(messages, receivesPayloadThat(is("ODD MEETS EVEN"))); - assertThat(messages, receivesPayloadThat(not("nothing but the best test"))); - - Message testMessage = - MessageBuilder.withPayload("headers") - .setHeader("odd", "even") - .build(); - - input.send(testMessage); - - Message expected = - MessageBuilder.withPayload("HEADERS") - .copyHeaders(testMessage.getHeaders()) - .setHeader(MessageHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .build(); + this.input.send(new GenericMessage<>("even")); + result = this.output.receive(5000); + assertThat(result).isNotNull(); + assertThat(new String(result.getPayload())).isEqualTo("EVEN"); - Matcher> sameExceptIgnorableHeaders = - (Matcher>) (Matcher) sameExceptIgnorableHeaders(expected, "accept"); + this.input.send(new GenericMessage<>("odd meets even")); + result = this.output.receive(5000); + assertThat(result).isNotNull(); + assertThat(new String(result.getPayload())).isEqualTo("ODD MEETS EVEN"); - assertThat(messages, receivesMessageThat(sameExceptIgnorableHeaders)); + this.input.send(new GenericMessage<>("nothing but the best test")); + result = this.output.receive(5000); + assertThat(result).isNotNull(); + assertThat(new String(result.getPayload())).isNotEqualTo("nothing but the best test"); + + this.input.send(new GenericMessage<>("headers")); + result = this.output.receive(5000); + assertThat(result).isNotNull(); + assertThat(new String(result.getPayload())).isEqualTo("HEADERS"); } } diff --git a/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/processor/integration/ToUpperCaseProcessorIntTests.java b/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/processor/integration/ToUpperCaseProcessorIntTests.java index 1ea61e23..b8d65a84 100644 --- a/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/processor/integration/ToUpperCaseProcessorIntTests.java +++ b/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/processor/integration/ToUpperCaseProcessorIntTests.java @@ -27,11 +27,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration; +import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; +import org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration; +import org.springframework.boot.transaction.autoconfigure.TransactionAutoConfiguration; import org.springframework.cloud.stream.testing.processor.ToUpperCaseProcessor; import org.springframework.kafka.core.DefaultKafkaConsumerFactory; import org.springframework.kafka.core.KafkaTemplate; @@ -58,7 +57,6 @@ classes = ToUpperCaseProcessor.class, webEnvironment = SpringBootTest.WebEnvironment.NONE) @ImportAutoConfiguration(exclude = { - TestSupportBinderAutoConfiguration.class, DataSourceAutoConfiguration.class, TransactionAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class }) diff --git a/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/sink/JdbcSinkTests.java b/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/sink/JdbcSinkTests.java index 27059ecd..0dc76093 100644 --- a/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/sink/JdbcSinkTests.java +++ b/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/sink/JdbcSinkTests.java @@ -30,11 +30,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.actuate.autoconfigure.metrics.KafkaMetricsAutoConfiguration; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration; +import org.springframework.boot.kafka.autoconfigure.KafkaAutoConfiguration; +import org.springframework.boot.kafka.autoconfigure.metrics.KafkaMetricsAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; import org.springframework.integration.channel.AbstractMessageChannel; import org.springframework.integration.test.mock.MockIntegration; import org.springframework.jdbc.core.JdbcTemplate; @@ -66,7 +66,7 @@ class JdbcSinkTests { @Autowired private JdbcTemplate jdbcTemplate; - @SpyBean(name = "jdbcHandler") + @MockitoSpyBean(name = "jdbcHandler") private MessageHandler jdbcMessageHandler; @Test diff --git a/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/source/OddEvenSourceTests.java b/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/source/OddEvenSourceTests.java index d642dc3f..92eb9d58 100644 --- a/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/source/OddEvenSourceTests.java +++ b/testing-samples/testing-demo/src/test/java/org/springframework/cloud/stream/testing/source/OddEvenSourceTests.java @@ -17,26 +17,21 @@ package org.springframework.cloud.stream.testing.source; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.springframework.cloud.stream.test.matcher.MessageQueueMatcher.receivesPayloadThat; - -import java.util.concurrent.BlockingQueue; +import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.actuate.autoconfigure.metrics.KafkaMetricsAutoConfiguration; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; -import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration; -import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration; +import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; +import org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration; +import org.springframework.boot.kafka.autoconfigure.KafkaAutoConfiguration; +import org.springframework.boot.kafka.autoconfigure.metrics.KafkaMetricsAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.stream.test.binder.MessageCollector; +import org.springframework.boot.transaction.autoconfigure.TransactionAutoConfiguration; +import org.springframework.cloud.stream.binder.test.OutputDestination; +import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration; import org.springframework.messaging.Message; -import org.springframework.messaging.MessageChannel; import org.springframework.test.annotation.DirtiesContext; /** @@ -48,7 +43,8 @@ */ @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.NONE, - properties = "spring.cloud.stream.poller.fixed-delay=1") + properties = "spring.cloud.stream.poller.fixed-delay=1", + classes = { OddEvenSource.class, TestChannelBinderConfiguration.class }) @ImportAutoConfiguration(exclude = { KafkaAutoConfiguration.class, KafkaMetricsAutoConfiguration.class, @@ -59,20 +55,25 @@ class OddEvenSourceTests { @Autowired - @Qualifier("oddEvenSupplier-out-0") - MessageChannel outputDestination; - - @Autowired - MessageCollector collector; + private OutputDestination output; @Test void testMessages() { - BlockingQueue> messages = this.collector.forChannel(this.outputDestination); + Message result = this.output.receive(5000); + assertThat(result).isNotNull(); + assertThat(new String(result.getPayload())).isEqualTo("odd"); + + result = this.output.receive(5000); + assertThat(result).isNotNull(); + assertThat(new String(result.getPayload())).isEqualTo("even"); + + result = this.output.receive(5000); + assertThat(result).isNotNull(); + assertThat(new String(result.getPayload())).isEqualTo("odd"); - assertThat(messages, receivesPayloadThat(is("odd"))); - assertThat(messages, receivesPayloadThat(is("even"))); - assertThat(messages, receivesPayloadThat(is("odd"))); - assertThat(messages, receivesPayloadThat(is("even"))); + result = this.output.receive(5000); + assertThat(result).isNotNull(); + assertThat(new String(result.getPayload())).isEqualTo("even"); } } diff --git a/transaction-kafka-samples/pom.xml b/transaction-kafka-samples/pom.xml index 66b2789e..17858610 100644 --- a/transaction-kafka-samples/pom.xml +++ b/transaction-kafka-samples/pom.xml @@ -1,6 +1,12 @@ 4.0.0 + + io.spring.cloud.stream.sample + spring-cloud-stream-samples-parent + 0.0.1-SNAPSHOT + .. + io.spring.cloud.stream.sample transaction-kafka-samples 0.0.1-SNAPSHOT diff --git a/transaction-kafka-samples/transaction-http-source/pom.xml b/transaction-kafka-samples/transaction-http-source/pom.xml index d884ffdc..7487913e 100644 --- a/transaction-kafka-samples/transaction-http-source/pom.xml +++ b/transaction-kafka-samples/transaction-http-source/pom.xml @@ -9,28 +9,12 @@ Transaction http source - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + transaction-kafka-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -56,7 +40,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -69,54 +53,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - + diff --git a/transaction-kafka-samples/transaction-logger-sink/pom.xml b/transaction-kafka-samples/transaction-logger-sink/pom.xml index 1fa3dc26..d41a580a 100644 --- a/transaction-kafka-samples/transaction-logger-sink/pom.xml +++ b/transaction-kafka-samples/transaction-logger-sink/pom.xml @@ -9,28 +9,12 @@ Schema Registry Consumer - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + transaction-kafka-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -56,7 +40,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc @@ -69,54 +53,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - + diff --git a/transaction-kafka-samples/transaction-spring-data-processor/pom.xml b/transaction-kafka-samples/transaction-spring-data-processor/pom.xml index e01d7512..4b02861e 100644 --- a/transaction-kafka-samples/transaction-spring-data-processor/pom.xml +++ b/transaction-kafka-samples/transaction-spring-data-processor/pom.xml @@ -10,28 +10,12 @@ - org.springframework.boot - spring-boot-starter-parent - 2.4.4 - + io.spring.cloud.stream.sample + transaction-kafka-samples + 0.0.1-SNAPSHOT + .. - - 2020.0.2 - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - org.springframework.cloud @@ -57,7 +41,7 @@ org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webmvc org.springframework.boot @@ -66,7 +50,7 @@ org.mariadb.jdbc mariadb-java-client - 1.1.9 + 3.5.1 runtime @@ -80,54 +64,5 @@ - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/libs-snapshot-local - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/libs-milestone-local - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/libs-release-local - - false - - - + diff --git a/transaction-kafka-samples/transaction-spring-data-processor/src/main/java/sample/processor/Person.java b/transaction-kafka-samples/transaction-spring-data-processor/src/main/java/sample/processor/Person.java index 51d76405..fdb79294 100644 --- a/transaction-kafka-samples/transaction-spring-data-processor/src/main/java/sample/processor/Person.java +++ b/transaction-kafka-samples/transaction-spring-data-processor/src/main/java/sample/processor/Person.java @@ -18,14 +18,14 @@ import java.util.Objects; import java.util.StringJoiner; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.UniqueConstraint; -import javax.validation.constraints.Max; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.UniqueConstraint; +import jakarta.validation.constraints.Max; import org.hibernate.validator.constraints.Length; diff --git a/transaction-kafka-samples/transaction-spring-data-processor/src/main/java/sample/processor/ProcessorApplication.java b/transaction-kafka-samples/transaction-spring-data-processor/src/main/java/sample/processor/ProcessorApplication.java index c0a28ece..4f35756f 100644 --- a/transaction-kafka-samples/transaction-spring-data-processor/src/main/java/sample/processor/ProcessorApplication.java +++ b/transaction-kafka-samples/transaction-spring-data-processor/src/main/java/sample/processor/ProcessorApplication.java @@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; -import javax.transaction.Transactional; +import jakarta.transaction.Transactional; import org.slf4j.Logger; import org.slf4j.LoggerFactory;