diff --git a/schema-registry-samples/pom.xml b/schema-registry-samples/pom.xml index 1155aab..c3cb4a0 100644 --- a/schema-registry-samples/pom.xml +++ b/schema-registry-samples/pom.xml @@ -9,7 +9,8 @@ Schema Registry Samples - schema-registry-vanilla + schema-registry-vanilla-kafka-binder + schema-registry-vanilla-rabbit-binder schema-registry-confluent schema-registry-confluent-avro-serializer kafka-streams-schema-evolution diff --git a/schema-registry-samples/schema-registry-vanilla/.mvn b/schema-registry-samples/schema-registry-vanilla-kafka-binder/.mvn similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/.mvn rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/.mvn diff --git a/schema-registry-samples/schema-registry-vanilla/README.adoc b/schema-registry-samples/schema-registry-vanilla-kafka-binder/README.adoc similarity index 73% rename from schema-registry-samples/schema-registry-vanilla/README.adoc rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/README.adoc index 1396ced..6a92c2b 100644 --- a/schema-registry-samples/schema-registry-vanilla/README.adoc +++ b/schema-registry-samples/schema-registry-vanilla-kafka-binder/README.adoc @@ -1,7 +1,7 @@ -== Spring Cloud Stream and Schema Evolution in Action! +== Spring Cloud Stream and Schema Evolution in Action with Kafka Binder. -This repo includes four Spring Boot applications to demonstrate Schema Evolution using Spring Cloud Stream. A Schema Registry -(`registry`), Producer V1 (`producer1`), Producer V2 (`producer2`), and Consumer (`consumer`) are included in this project. +These are a set of Spring Boot applications to demonstrate Schema Evolution using Spring Cloud Stream with Kafka binder. +Producer V1 (`producer1`), Producer V2 (`producer2`), and Consumer (`consumer`) are included in this project. === Requirement As a developer, I'd like to design my consumer to be resilient to differing payload schemas. @@ -11,42 +11,44 @@ There are a lot of online literature on Schema Evolution, so we are going to ski however, we will simply assume there are two producers producing events with different payload schemas. A consumer that consumes both the payload versions will be designed to adapt to evolving schemas. +These applications integrate with Spring provided scheam registry. +Both producers and consumers interact with this scheam registry to register and evolve the schema. + === Running the application -Make sure you are in the directory `schema-registry-vanilla` +Make sure you are in the directory `schema-registry-vanilla-kafka-binder` -Choose a middleware +Start Kafka -For kafka: `docker-compose up -d` -For Rabbitmq: `docker-compose -f docker-compose-rabbit.yml up -d` +`docker-compose up -d` -If you are using Kafka binder: `./mvnw clean package` -If you are using RabbitMQ binder: `./mvnw clean package -P rabbit-binder` +Build the applications: `./mvnw clean package` -- Start the Schema Registry server +- Start the Schema Registry server (Chnage these commands accordingly if you are not on a Unix like platform) [source,bash] ---- -java -jar schema-registry-vanilla-server/target/schema-registry-vanilla-server-0.0.1-SNAPSHOT.jar +wget -O /tmp/schema-registry-server.jar https://repo.spring.io/libs-snapshot-local/org/springframework/cloud/spring-cloud-schema-registry-server/1.0.0.BUILD-SNAPSHOT/spring-cloud-schema-registry-server-1.0.0.BUILD-SNAPSHOT.jar +cd /tmp +java -jar schema-registry-server-1.0.0.BUILD-SNAPSHOT.jar ---- -- Start `consumer` on another terminal session +- Start `consumer` on another terminal session (or run it from an IDE) [source,bash] ---- -java -jar schema-registry-vanilla-consumer/target/schema-registry-vanilla-consumer-0.0.1-SNAPSHOT.jar +java -jar schema-registry-vanilla-consumer-kafka/target/schema-registry-vanilla-consumer-kafka-0.0.1-SNAPSHOT.jar ---- - If you want to see how a Spring Cloud Stream application with Kafka Streams work with the schema registry, start the Kafka Streams consumer application. -This step only works, if you are using Kafka as the middleware. ---- java -jar kafka-streams-consumer/target/kafka-streams-consumer-0.0.1-SNAPSHOT.jar ---- -- Start `producer1` on another terminal session +- Start `producer1` on another terminal session (or run it from an IDE) [source,bash] ---- -java -jar schema-registry-vanilla-producer1/target/schema-registry-vanilla-producer1-0.0.1-SNAPSHOT.jar +java -jar schema-registry-vanilla-producer1-kafka/target/schema-registry-vanilla-producer1-kafka-0.0.1-SNAPSHOT.jar ---- -- Start `producer2` on another terminal session +- Start `producer2` on another terminal session (or run it from an IDE) [source,bash] ---- -java -jar schema-registry-vanilla-producer2/target/schema-registry-vanilla-producer2-0.0.1-SNAPSHOT.jar +java -jar schema-registry-vanilla-producer2-kafka/target/schema-registry-vanilla-producer2-kafka-0.0.1-SNAPSHOT.jar ---- === Sample Data @@ -106,8 +108,6 @@ Registry server and Avro, the schema evolution occurs behind the scenes. The aut === Cleanup -Once you are done with running the samples, stop the docker containers +Once you are done with running the samples, stop the docker container `docker-compose down` - -of `docker-compose -f docker-compose-rabbit.yml down` if you are using the Rabbit binder. \ No newline at end of file diff --git a/schema-registry-samples/schema-registry-vanilla/docker-compose.yml b/schema-registry-samples/schema-registry-vanilla-kafka-binder/docker-compose.yml similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/docker-compose.yml rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/docker-compose.yml diff --git a/schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/.mvn/jvm.config b/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/.mvn/jvm.config similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/.mvn/jvm.config rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/.mvn/jvm.config diff --git a/schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/.mvn/maven.config b/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/.mvn/maven.config similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/.mvn/maven.config rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/.mvn/maven.config diff --git a/schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/.mvn/wrapper/maven-wrapper.jar b/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/.mvn/wrapper/maven-wrapper.jar similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/.mvn/wrapper/maven-wrapper.jar rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/.mvn/wrapper/maven-wrapper.jar diff --git a/schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/.mvn/wrapper/maven-wrapper.properties b/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/.mvn/wrapper/maven-wrapper.properties similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/.mvn/wrapper/maven-wrapper.properties rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/.mvn/wrapper/maven-wrapper.properties diff --git a/schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/mvnw b/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/mvnw similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/mvnw rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/mvnw diff --git a/schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/mvnw.cmd b/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/mvnw.cmd similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/mvnw.cmd rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/mvnw.cmd diff --git a/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/pom.xml b/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/pom.xml new file mode 100644 index 0000000..04a4594 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/pom.xml @@ -0,0 +1,140 @@ + + + 4.0.0 + + kafka-streams-consumer + 0.0.1-SNAPSHOT + jar + kafka-streams-consumer + Schema Registry Consumer + + + org.springframework.boot + spring-boot-starter-parent + 2.2.0.BUILD-SNAPSHOT + + + + + 1.8.2 + Hoxton.BUILD-SNAPSHOT + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + org.springframework.cloud + spring-cloud-stream-binder-kafka + + + org.springframework.cloud + spring-cloud-schema-registry-client + + + org.apache.avro + avro + ${avro.version} + + + org.springframework.cloud + spring-cloud-stream-binder-kafka-streams + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.avro + avro-maven-plugin + ${avro.version} + + + generate-sources + + schema + protocol + idl-protocol + + + src/main/resources/avro + + + + + + + + + + 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/schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/src/main/java/sample/consumer/CountVersionApplication.java b/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/src/main/java/sample/consumer/CountVersionApplication.java similarity index 68% rename from schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/src/main/java/sample/consumer/CountVersionApplication.java rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/src/main/java/sample/consumer/CountVersionApplication.java index 8e9b912..697087e 100644 --- a/schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/src/main/java/sample/consumer/CountVersionApplication.java +++ b/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/src/main/java/sample/consumer/CountVersionApplication.java @@ -1,10 +1,15 @@ package sample.consumer; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; + import com.example.Sensor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.kafka.common.serialization.Serdes; import org.apache.kafka.streams.KeyValue; +import org.apache.kafka.streams.kstream.Grouped; import org.apache.kafka.streams.kstream.KStream; import org.apache.kafka.streams.kstream.Materialized; import org.apache.kafka.streams.kstream.Serialized; @@ -13,21 +18,14 @@ import org.apache.kafka.streams.state.ReadOnlyKeyValueStore; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.annotation.StreamListener; +import org.springframework.cloud.schema.registry.client.EnableSchemaRegistryClient; import org.springframework.cloud.stream.binder.kafka.streams.InteractiveQueryService; -import org.springframework.cloud.stream.binder.kafka.streams.annotations.KafkaStreamsProcessor; import org.springframework.cloud.stream.binder.kafka.streams.serde.CompositeNonNativeSerde; -import org.springframework.cloud.stream.schema.client.EnableSchemaRegistryClient; -import org.springframework.messaging.handler.annotation.SendTo; +import org.springframework.context.annotation.Bean; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; -import java.util.HashMap; -import java.util.Map; - @SpringBootApplication -@EnableBinding(KafkaStreamsProcessor.class) @EnableSchemaRegistryClient @EnableScheduling public class CountVersionApplication { @@ -41,8 +39,8 @@ public class CountVersionApplication { private InteractiveQueryService queryService; /**Serde to be used in Kafka Streams operations. This is a custom Serde that uses the same - * Avro message converter used by the inbound serialization by the framework. This Serde implmentation - * will interact with the Spring Cloud Stream provided Scheam Registry for resolving schema. */ + * Avro message converter used by the inbound serialization by the framework. This Serde implementation + * will interact with the Spring Cloud Stream provided Schema Registry for resolving schema. */ @Autowired private CompositeNonNativeSerde customSerde; @@ -50,27 +48,26 @@ public class CountVersionApplication { SpringApplication.run(CountVersionApplication.class, args); } - @StreamListener("input") - @SendTo("output") - public KStream process(KStream input) { + @Bean + public Function, KStream> process() { Map configs = new HashMap<>(); configs.put("valueClass", Sensor.class); configs.put("contentType", "application/*+avro"); customSerde.configure(configs, false); - return input - .map((key, value) -> { + return input -> input + .map((key, value) -> { - String newKey = "v1"; - if (value.getId().toString().endsWith("v2")) { - newKey = "v2"; - } - return new KeyValue<>(newKey, value); - }) - .groupByKey(Serialized.with(Serdes.String(), customSerde)) - .count(Materialized.as(STORE_NAME)) - .toStream(); + String newKey = "v1"; + if (value.getId().toString().endsWith("v2")) { + newKey = "v2"; + } + return new KeyValue<>(newKey, value); + }) + .groupByKey(Grouped.with(Serdes.String(), customSerde)) + .count(Materialized.as(STORE_NAME)) + .toStream(); } @Scheduled(fixedRate = 30000, initialDelay = 5000) diff --git a/schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/src/main/resources/application.yml b/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/src/main/resources/application.yml similarity index 66% rename from schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/src/main/resources/application.yml rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/src/main/resources/application.yml index a7da4d7..00fc2d9 100644 --- a/schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/src/main/resources/application.yml +++ b/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/src/main/resources/application.yml @@ -13,14 +13,12 @@ spring.cloud.stream.kafka.streams: binder.configuration: default.key.serde: org.apache.kafka.common.serialization.Serdes$StringSerde default.value.serde: org.apache.kafka.common.serialization.Serdes$StringSerde - bindings.output.producer: - keySerde: org.apache.kafka.common.serialization.Serdes$StringSerde - valueSerde: org.apache.kafka.common.serialization.Serdes$LongSerde -spring.cloud.stream.bindings.output: +spring.cloud.stream.bindings.process_out: destination: sensor-counts -spring.cloud.stream.bindings.input: +spring.cloud.stream.bindings.process_in: destination: sensor-topic spring.cloud.stream.kafka.streams.binder: brokers: localhost #192.168.99.100 -spring.cloud.stream.kafka.streams.bindings.input.consumer.application-id: schema-reg-vanilla-demo-app \ No newline at end of file +spring.cloud.stream.kafka.streams.binder.process.application-id: schema-reg-vanilla-demo-app-x-1 +spring.cloud.stream.bindings.process_in.consumer.useNativeDecoding: false \ No newline at end of file diff --git a/schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/src/main/resources/avro/sensor.avsc b/schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/src/main/resources/avro/sensor.avsc similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/src/main/resources/avro/sensor.avsc rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/kafka-streams-consumer/src/main/resources/avro/sensor.avsc diff --git a/schema-registry-samples/schema-registry-vanilla/mvnw b/schema-registry-samples/schema-registry-vanilla-kafka-binder/mvnw similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/mvnw rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/mvnw diff --git a/schema-registry-samples/schema-registry-vanilla/mvnw.cmd b/schema-registry-samples/schema-registry-vanilla-kafka-binder/mvnw.cmd similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/mvnw.cmd rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/mvnw.cmd diff --git a/schema-registry-samples/schema-registry-vanilla/pom.xml b/schema-registry-samples/schema-registry-vanilla-kafka-binder/pom.xml similarity index 63% rename from schema-registry-samples/schema-registry-vanilla/pom.xml rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/pom.xml index 2a0ac24..16b2526 100644 --- a/schema-registry-samples/schema-registry-vanilla/pom.xml +++ b/schema-registry-samples/schema-registry-vanilla-kafka-binder/pom.xml @@ -2,17 +2,16 @@ 4.0.0 io.spring.cloud.stream.sample - schema-registry-vanilla + schema-registry-vanilla-kafka-binder 0.0.1-SNAPSHOT pom - schema-registry-vanilla + schema-registry-vanilla-kafka-binder Schema Registry Vanilla Sample - schema-registry-vanilla-producer1 - schema-registry-vanilla-producer2 - schema-registry-vanilla-consumer - schema-registry-vanilla-server + schema-registry-vanilla-producer1-kafka + schema-registry-vanilla-producer2-kafka + schema-registry-vanilla-consumer-kafka kafka-streams-consumer diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/.mvn b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/.mvn similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/.mvn rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/.mvn diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/mvnw b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/mvnw similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/mvnw rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/mvnw diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/mvnw.cmd b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/mvnw.cmd similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/mvnw.cmd rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/mvnw.cmd diff --git a/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/pom.xml b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/pom.xml new file mode 100644 index 0000000..c228b6b --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/pom.xml @@ -0,0 +1,137 @@ + + + 4.0.0 + + schema-registry-vanilla-consumer-kafka + 0.0.1-SNAPSHOT + jar + schema-registry-vanilla-consumer-kafka + Schema Registry Consumer + + + org.springframework.boot + spring-boot-starter-parent + 2.2.0.BUILD-SNAPSHOT + + + + + 1.8.2 + Hoxton.BUILD-SNAPSHOT + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + + org.springframework.cloud + spring-cloud-stream-binder-kafka + + + org.springframework.cloud + spring-cloud-schema-registry-client + + + org.apache.avro + avro + ${avro.version} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.avro + avro-maven-plugin + ${avro.version} + + + generate-sources + + schema + protocol + idl-protocol + + + src/main/resources/avro + + + + + + + + + + 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/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/src/main/java/sample/consumer/ConsumerApplication.java b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/src/main/java/sample/consumer/ConsumerApplication.java similarity index 57% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/src/main/java/sample/consumer/ConsumerApplication.java rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/src/main/java/sample/consumer/ConsumerApplication.java index c8562dd..9d003c0 100644 --- a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/src/main/java/sample/consumer/ConsumerApplication.java +++ b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/src/main/java/sample/consumer/ConsumerApplication.java @@ -1,17 +1,16 @@ package sample.consumer; +import java.util.function.Consumer; + import com.example.Sensor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.annotation.StreamListener; -import org.springframework.cloud.stream.messaging.Sink; -import org.springframework.cloud.stream.schema.client.EnableSchemaRegistryClient; +import org.springframework.cloud.schema.registry.client.EnableSchemaRegistryClient; +import org.springframework.context.annotation.Bean; @SpringBootApplication -@EnableBinding(Sink.class) @EnableSchemaRegistryClient public class ConsumerApplication { @@ -21,8 +20,9 @@ public class ConsumerApplication { SpringApplication.run(ConsumerApplication.class, args); } - @StreamListener(Sink.INPUT) - public void process(Sensor data) { - logger.info(data); + @Bean + public Consumer process() { + return input -> logger.info("input: " + input); } + } \ No newline at end of file diff --git a/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/src/main/resources/application.yml b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/src/main/resources/application.yml new file mode 100644 index 0000000..3bcfb28 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/src/main/resources/application.yml @@ -0,0 +1,13 @@ +spring: + cloud: + stream: + bindings: + input: + destination: sensor-topic + schema-registry-client: + endpoint: http://localhost:8990 + schema: + avro: + schema-locations: classpath:avro/sensor.avsc +server.port: 9999 +spring.cloud.stream.function.definition: process \ No newline at end of file diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/src/main/resources/avro/sensor.avsc b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/src/main/resources/avro/sensor.avsc similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/src/main/resources/avro/sensor.avsc rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-consumer-kafka/src/main/resources/avro/sensor.avsc diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/.mvn b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/.mvn similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/.mvn rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/.mvn diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/mvnw b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/mvnw similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/mvnw rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/mvnw diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/mvnw.cmd b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/mvnw.cmd similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/mvnw.cmd rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/mvnw.cmd diff --git a/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/pom.xml b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/pom.xml new file mode 100644 index 0000000..1d1a032 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/pom.xml @@ -0,0 +1,137 @@ + + + 4.0.0 + + schema-registry-vanilla-producer1-kafka + 0.0.1-SNAPSHOT + jar + schema-registry-vanilla-producer1-kafka + Schema Registry Producer1 + + + org.springframework.boot + spring-boot-starter-parent + 2.2.0.BUILD-SNAPSHOT + + + + + 1.8.2 + Hoxton.BUILD-SNAPSHOT + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + + org.springframework.cloud + spring-cloud-stream-binder-kafka + + + org.springframework.cloud + spring-cloud-schema-registry-client + + + org.apache.avro + avro + ${avro.version} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.avro + avro-maven-plugin + ${avro.version} + + + generate-sources + + schema + protocol + idl-protocol + + + src/main/resources/avro + + + + + + + + + + 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/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/src/main/java/sample/producer1/Producer1ApplicationKafka.java b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/src/main/java/sample/producer1/Producer1ApplicationKafka.java new file mode 100644 index 0000000..94a2d41 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/src/main/java/sample/producer1/Producer1ApplicationKafka.java @@ -0,0 +1,52 @@ +package sample.producer1; + +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.function.Supplier; + +import com.example.Sensor; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.schema.registry.client.EnableSchemaRegistryClient; +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +@SpringBootApplication +@EnableSchemaRegistryClient +@RestController +public class Producer1ApplicationKafka { + + private Random random = new Random(); + + BlockingQueue unbounded = new LinkedBlockingQueue<>(); + + public static void main(String[] args) { + SpringApplication.run(Producer1ApplicationKafka.class, args); + } + + private Sensor randomSensor() { + Sensor sensor = new Sensor(); + sensor.setId(UUID.randomUUID().toString() + "-v1"); + sensor.setAcceleration(random.nextFloat() * 10); + sensor.setVelocity(random.nextFloat() * 100); + sensor.setTemperature(random.nextFloat() * 50); + return sensor; + } + + @RequestMapping(value = "/messages", method = RequestMethod.POST) + public String sendMessage() { + unbounded.offer(randomSensor()); + return "ok, have fun with v1 payload!"; + } + + @Bean + public Supplier supplier() { + return () -> unbounded.poll(); + } +} + diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/src/main/resources/application.yml b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/src/main/resources/application.yml similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/src/main/resources/application.yml rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/src/main/resources/application.yml diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/src/main/resources/avro/sensor.avsc b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/src/main/resources/avro/sensor.avsc similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/src/main/resources/avro/sensor.avsc rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer1-kafka/src/main/resources/avro/sensor.avsc diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/.mvn b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/.mvn similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/.mvn rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/.mvn diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/mvnw b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/mvnw similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/mvnw rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/mvnw diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/mvnw.cmd b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/mvnw.cmd similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/mvnw.cmd rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/mvnw.cmd diff --git a/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/pom.xml b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/pom.xml new file mode 100644 index 0000000..86fbc49 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/pom.xml @@ -0,0 +1,137 @@ + + + 4.0.0 + + schema-registry-vanilla-producer2-kafka + 0.0.1-SNAPSHOT + jar + schema-registry-vanilla-producer2-kafka + Schema Registry producer2 + + + org.springframework.boot + spring-boot-starter-parent + 2.2.0.BUILD-SNAPSHOT + + + + + 1.8.2 + Hoxton.BUILD-SNAPSHOT + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + + org.springframework.cloud + spring-cloud-stream-binder-kafka + + + org.springframework.cloud + spring-cloud-schema-registry-client + + + org.apache.avro + avro + ${avro.version} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.avro + avro-maven-plugin + ${avro.version} + + + generate-sources + + schema + protocol + idl-protocol + + + src/main/resources/avro + + + + + + + + + + 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/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/src/main/java/sample/producer2/Producer2ApplicationRabbit.java b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/src/main/java/sample/producer2/Producer2ApplicationRabbit.java new file mode 100644 index 0000000..7d87af9 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/src/main/java/sample/producer2/Producer2ApplicationRabbit.java @@ -0,0 +1,54 @@ +package sample.producer2; + +import com.example.Sensor; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.schema.registry.client.EnableSchemaRegistryClient; +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.function.Supplier; + +@SpringBootApplication +@EnableSchemaRegistryClient +@RestController +public class Producer2ApplicationRabbit { + + private Random random = new Random(); + + BlockingQueue unbounded = new LinkedBlockingQueue<>(); + + public static void main(String[] args) { + SpringApplication.run(Producer2ApplicationRabbit.class, args); + } + + @RequestMapping(value = "/messages", method = RequestMethod.POST) + public String sendMessage() { + unbounded.offer(randomSensor()); + return "ok, have fun with v2 payload!"; + } + + @Bean + public Supplier supplier() { + return () -> unbounded.poll(); + } + + private Sensor randomSensor() { + Sensor sensor = new Sensor(); + sensor.setId(UUID.randomUUID().toString() + "-v2"); + sensor.setAcceleration(random.nextFloat() * 10); + sensor.setVelocity(random.nextFloat() * 100); + sensor.setInternalTemperature(random.nextFloat() * 50); + sensor.setExternalTemperature(random.nextFloat() * 50); + sensor.setAccelerometer(null); + sensor.setMagneticField(null); + return sensor; + } +} + diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/src/main/resources/application.yml b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/src/main/resources/application.yml similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/src/main/resources/application.yml rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/src/main/resources/application.yml diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/src/main/resources/avro/sensor.avsc b/schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/src/main/resources/avro/sensor.avsc similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/src/main/resources/avro/sensor.avsc rename to schema-registry-samples/schema-registry-vanilla-kafka-binder/schema-registry-vanilla-producer2-kafka/src/main/resources/avro/sensor.avsc diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/.mvn b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/.mvn new file mode 120000 index 0000000..d21aa17 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/.mvn @@ -0,0 +1 @@ +../../.mvn \ No newline at end of file diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/README.adoc b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/README.adoc new file mode 100644 index 0000000..8cd7b61 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/README.adoc @@ -0,0 +1,95 @@ +== Spring Cloud Stream and Schema Evolution in Action! + +These are a set of Spring Boot applications to demonstrate Schema Evolution using Spring Cloud Stream with rabbit binder. +Producer V1 (`producer1`), Producer V2 (`producer2`), and Consumer (`consumer`) are included in this project. + +=== Requirement +As a developer, I'd like to design my consumer to be resilient to differing payload schemas. + +=== Assumptions +There are a lot of online literature on Schema Evolution, so we are going to skip defining them here. For this demonstration, +however, we will simply assume there are two producers producing events with different payload schemas. A consumer that +consumes both the payload versions will be designed to adapt to evolving schemas. + +=== Running the application + +Make sure you are in the directory `schema-registry-vanilla-rabbit-binder` + +Start rabbit + +`docker-compose up -d` + +Build the applications: `./mvnw clean package` + +- Start the Schema Registry server (Chnage these commands accordingly if you are not on a Unix like platform) +[source,bash] +---- +wget -O /tmp/schema-registry-server.jar https://repo.spring.io/libs-snapshot-local/org/springframework/cloud/spring-cloud-schema-registry-server/1.0.0.BUILD-SNAPSHOT/spring-cloud-schema-registry-server-1.0.0.BUILD-SNAPSHOT.jar +cd /tmp +java -jar schema-registry-server.jar +---- +- Start `consumer` on another terminal session (or run it from an IDE) +[source,bash] +---- +java -jar schema-registry-vanilla-consumer-rabbit/target/schema-registry-vanilla-consumer-rabbit-0.0.1-SNAPSHOT.jar +---- +- Start `producer1` on another terminal session (or run it from an IDE) +[source,bash] +---- +java -jar schema-registry-vanilla-producer1-rabbit/target/schema-registry-vanilla-producer1-rabbit-0.0.1-SNAPSHOT.jar +---- +- Start `producer2` on another terminal session (or run it from an IDE) +[source,bash] +---- +java -jar schema-registry-vanilla-producer2-rabbit/target/schema-registry-vanilla-producer2-rabbit-0.0.1-SNAPSHOT.jar +---- + +=== Sample Data +Both the producers in the demonstration are _also_ REST controllers. We will hit the `/messages` endpoint on each producer +to POST sample data. + +_Example:_ +[source,bash] +---- +curl -X POST http://localhost:9009/messages +curl -X POST http://localhost:9010/messages +curl -X POST http://localhost:9009/messages +curl -X POST http://localhost:9009/messages +curl -X POST http://localhost:9010/messages +---- + +=== Output +The consumer should log the results. + +[source,bash,options=nowrap,subs=attributes] +---- +{"id": "d135efc3-72f8-4612-9497-184cae508e31-v1", "internalTemperature": 34.36362, "externalTemperature": 0.0, "acceleration": 9.656547, "velocity": 33.29733} +{"id": "fd2467ce-ae09-4fd4-9cde-d9ff33fac89b-v2", "internalTemperature": 34.840473, "externalTemperature": 0.0, "acceleration": 9.709609, "velocity": 23.046476} +{"id": "4ac70c32-9ffe-4c90-914a-fa28024f5faa-v1", "internalTemperature": 23.74807, "externalTemperature": 0.0, "acceleration": 7.5003176, "velocity": 15.848035} +{"id": "3ecaae18-3144-4570-800a-223ca3198001-v1", "internalTemperature": 28.410656, "externalTemperature": 0.0, "acceleration": 1.752817, "velocity": 69.82016} +{"id": "149637a9-c7a6-4ab8-b7aa-021c72d9ebd7-v2", "internalTemperature": 2.2332578, "externalTemperature": 0.0, "acceleration": 6.251889, "velocity": 65.84996} +---- + +NOTE: Refer to the payload suffix in the `id` field. Each of them are appended with `-v1` or `-v2` indicating they are from +`producer1` and `producer2` respectively. + +=== What just happened? +The schema evolved on the `temperature` field. That field is now split into `internalTemperature` and `externalTemperature`, +as two separate fields. The `producer1` produces payload only with `temperature` and on the other hand, `producer2` produces +payload with `internalTemperature` and `externalTemperature` fields in it. + +The `consumer` is coded against a base schema that include the split fields. + +The `consumer` app can happily deserialize the payload with `internalTemperature` and `externalTemperature` fields. However, when +a `producer1` payload arrives (which includes `temperature` field), the schema evolution and compatibility check are automatically +applied. + +Because each payload also includes the payload version in the header, Spring Cloud Stream with the help of Schema +Registry server and Avro, the schema evolution occurs behind the scenes. The automatic mapping of `temperature` to +`internalTemperature` field is applied, since that's the field where the `aliases` is defined in the link:https://github.com/sabbyanandan/schema/blob/master/consumer/src/main/resources/avro/sensor.avsc#L7[new schema]. + +=== Cleanup + +Once you are done with running the samples, stop the docker container + +`docker-compose down` diff --git a/schema-registry-samples/schema-registry-vanilla/docker-compose-rabbit.yml b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/docker-compose.yml similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/docker-compose-rabbit.yml rename to schema-registry-samples/schema-registry-vanilla-rabbit-binder/docker-compose.yml diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/mvnw b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/mvnw similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/mvnw rename to schema-registry-samples/schema-registry-vanilla-rabbit-binder/mvnw diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/mvnw.cmd b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/mvnw.cmd similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/mvnw.cmd rename to schema-registry-samples/schema-registry-vanilla-rabbit-binder/mvnw.cmd diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/pom.xml b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/pom.xml new file mode 100644 index 0000000..af144cd --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + io.spring.cloud.stream.sample + schema-registry-vanilla-rabbit-binder + 0.0.1-SNAPSHOT + pom + schema-registry-vanilla + Schema Registry Vanilla Sample + + + schema-registry-vanilla-producer1-rabbit + schema-registry-vanilla-producer2-rabbit + schema-registry-vanilla-consumer-rabbit + + + diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/.mvn b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/.mvn new file mode 120000 index 0000000..71491fb --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/.mvn @@ -0,0 +1 @@ +../../../.mvn \ No newline at end of file diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/mvnw b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/mvnw new file mode 100755 index 0000000..0ce08e9 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/mvnw @@ -0,0 +1,226 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +echo $MAVEN_PROJECTBASEDIR +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +"$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" + diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/mvnw.cmd b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/mvnw.cmd new file mode 100644 index 0000000..7ecd01d --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/mvnw.cmd @@ -0,0 +1,145 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/pom.xml b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/pom.xml new file mode 100644 index 0000000..719db70 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/pom.xml @@ -0,0 +1,137 @@ + + + 4.0.0 + + schema-registry-vanilla-consumer-rabbit + 0.0.1-SNAPSHOT + jar + schema-registry-vanilla-consumer-rabbit + Schema Registry Consumer + + + org.springframework.boot + spring-boot-starter-parent + 2.2.0.BUILD-SNAPSHOT + + + + + 1.8.2 + Hoxton.BUILD-SNAPSHOT + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + + org.springframework.cloud + spring-cloud-stream-binder-rabbit + + + org.springframework.cloud + spring-cloud-schema-registry-client + + + org.apache.avro + avro + ${avro.version} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.avro + avro-maven-plugin + ${avro.version} + + + generate-sources + + schema + protocol + idl-protocol + + + src/main/resources/avro + + + + + + + + + + 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/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/src/main/java/sample/consumer/ConsumerApplication.java b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/src/main/java/sample/consumer/ConsumerApplication.java new file mode 100644 index 0000000..0b12c55 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/src/main/java/sample/consumer/ConsumerApplication.java @@ -0,0 +1,28 @@ +package sample.consumer; + +import java.util.function.Consumer; + +import com.example.Sensor; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.schema.registry.client.EnableSchemaRegistryClient; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +@EnableSchemaRegistryClient +public class ConsumerApplication { + + private final Log logger = LogFactory.getLog(getClass()); + + public static void main(String[] args) { + SpringApplication.run(ConsumerApplication.class, args); + } + + @Bean + public Consumer process() { + return input -> logger.info("input: " + input); + } + +} \ No newline at end of file diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/src/main/resources/application.yml b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/src/main/resources/application.yml similarity index 100% rename from schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/src/main/resources/application.yml rename to schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/src/main/resources/application.yml diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/src/main/resources/avro/sensor.avsc b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/src/main/resources/avro/sensor.avsc new file mode 100644 index 0000000..95afdfc --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-consumer-rabbit/src/main/resources/avro/sensor.avsc @@ -0,0 +1,12 @@ +{ + "namespace" : "com.example", + "type" : "record", + "name" : "Sensor", + "fields" : [ + {"name":"id","type":"string"}, + {"name":"internalTemperature", "type":"float", "default":0.0, "aliases":["temperature"]}, + {"name":"externalTemperature", "type":"float", "default":0.0}, + {"name":"acceleration", "type":"float","default":0.0}, + {"name":"velocity","type":"float","default":0.0} + ] +} \ No newline at end of file diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/.mvn b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/.mvn new file mode 120000 index 0000000..71491fb --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/.mvn @@ -0,0 +1 @@ +../../../.mvn \ No newline at end of file diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/mvnw b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/mvnw new file mode 100755 index 0000000..0ce08e9 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/mvnw @@ -0,0 +1,226 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +echo $MAVEN_PROJECTBASEDIR +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +"$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" + diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/mvnw.cmd b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/mvnw.cmd new file mode 100644 index 0000000..7ecd01d --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/mvnw.cmd @@ -0,0 +1,145 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/pom.xml b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/pom.xml new file mode 100644 index 0000000..e2a3f39 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/pom.xml @@ -0,0 +1,137 @@ + + + 4.0.0 + + schema-registry-vanilla-producer1-rabbit + 0.0.1-SNAPSHOT + jar + schema-registry-vanilla-producer1-rabbit + Schema Registry producer1 + + + org.springframework.boot + spring-boot-starter-parent + 2.2.0.BUILD-SNAPSHOT + + + + + 1.8.2 + Hoxton.BUILD-SNAPSHOT + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + + org.springframework.cloud + spring-cloud-stream-binder-rabbit + + + org.springframework.cloud + spring-cloud-schema-registry-client + + + org.apache.avro + avro + ${avro.version} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.avro + avro-maven-plugin + ${avro.version} + + + generate-sources + + schema + protocol + idl-protocol + + + src/main/resources/avro + + + + + + + + + + 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/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/src/main/java/sample/producer1/Producer1ApplicationRabbit.java b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/src/main/java/sample/producer1/Producer1ApplicationRabbit.java new file mode 100644 index 0000000..e1036df --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/src/main/java/sample/producer1/Producer1ApplicationRabbit.java @@ -0,0 +1,52 @@ +package sample.producer1; + +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.function.Supplier; + +import com.example.Sensor; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.schema.registry.client.EnableSchemaRegistryClient; +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +@SpringBootApplication +@EnableSchemaRegistryClient +@RestController +public class Producer1ApplicationRabbit { + + private Random random = new Random(); + + BlockingQueue unbounded = new LinkedBlockingQueue<>(); + + public static void main(String[] args) { + SpringApplication.run(Producer1ApplicationRabbit.class, args); + } + + private Sensor randomSensor() { + Sensor sensor = new Sensor(); + sensor.setId(UUID.randomUUID().toString() + "-v1"); + sensor.setAcceleration(random.nextFloat() * 10); + sensor.setVelocity(random.nextFloat() * 100); + sensor.setTemperature(random.nextFloat() * 50); + return sensor; + } + + @RequestMapping(value = "/messages", method = RequestMethod.POST) + public String sendMessage() { + unbounded.offer(randomSensor()); + return "ok, have fun with v1 payload!"; + } + + @Bean + public Supplier supplier() { + return () -> unbounded.poll(); + } +} + diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/src/main/resources/application.yml b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/src/main/resources/application.yml new file mode 100644 index 0000000..70c0c0d --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/src/main/resources/application.yml @@ -0,0 +1,13 @@ +spring: + cloud: + stream: + bindings: + output: + contentType: application/*+avro + destination: sensor-topic + schema-registry-client: + endpoint: http://localhost:8990 + schema: + avro: + schema-locations: classpath:avro/sensor.avsc +server.port: 9009 \ No newline at end of file diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/src/main/resources/avro/sensor.avsc b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/src/main/resources/avro/sensor.avsc new file mode 100644 index 0000000..c0e060d --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer1-rabbit/src/main/resources/avro/sensor.avsc @@ -0,0 +1,11 @@ +{ + "namespace" : "com.example", + "type" : "record", + "name" : "Sensor", + "fields" : [ + {"name":"id","type":"string"}, + {"name":"temperature", "type":"float", "default":0.0}, + {"name":"acceleration", "type":"float","default":0.0}, + {"name":"velocity","type":"float","default":0.0} + ] +} diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/.mvn b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/.mvn new file mode 120000 index 0000000..71491fb --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/.mvn @@ -0,0 +1 @@ +../../../.mvn \ No newline at end of file diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/mvnw b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/mvnw new file mode 100755 index 0000000..0ce08e9 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/mvnw @@ -0,0 +1,226 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +echo $MAVEN_PROJECTBASEDIR +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +"$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" + diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/mvnw.cmd b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/mvnw.cmd new file mode 100644 index 0000000..7ecd01d --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/mvnw.cmd @@ -0,0 +1,145 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/pom.xml b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/pom.xml new file mode 100644 index 0000000..2617cb0 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/pom.xml @@ -0,0 +1,137 @@ + + + 4.0.0 + + schema-registry-vanilla-producer2-rabbit + 0.0.1-SNAPSHOT + jar + schema-registry-vanilla-producer2-rabbit + Schema Registry producer2 + + + org.springframework.boot + spring-boot-starter-parent + 2.2.0.BUILD-SNAPSHOT + + + + + 1.8.2 + Hoxton.BUILD-SNAPSHOT + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + + org.springframework.cloud + spring-cloud-stream-binder-rabbit + + + org.springframework.cloud + spring-cloud-schema-registry-client + + + org.apache.avro + avro + ${avro.version} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.avro + avro-maven-plugin + ${avro.version} + + + generate-sources + + schema + protocol + idl-protocol + + + src/main/resources/avro + + + + + + + + + + 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/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/src/main/java/sample/producer2/Producer2ApplicationRabbit.java b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/src/main/java/sample/producer2/Producer2ApplicationRabbit.java new file mode 100644 index 0000000..7d87af9 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/src/main/java/sample/producer2/Producer2ApplicationRabbit.java @@ -0,0 +1,54 @@ +package sample.producer2; + +import com.example.Sensor; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.schema.registry.client.EnableSchemaRegistryClient; +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.function.Supplier; + +@SpringBootApplication +@EnableSchemaRegistryClient +@RestController +public class Producer2ApplicationRabbit { + + private Random random = new Random(); + + BlockingQueue unbounded = new LinkedBlockingQueue<>(); + + public static void main(String[] args) { + SpringApplication.run(Producer2ApplicationRabbit.class, args); + } + + @RequestMapping(value = "/messages", method = RequestMethod.POST) + public String sendMessage() { + unbounded.offer(randomSensor()); + return "ok, have fun with v2 payload!"; + } + + @Bean + public Supplier supplier() { + return () -> unbounded.poll(); + } + + private Sensor randomSensor() { + Sensor sensor = new Sensor(); + sensor.setId(UUID.randomUUID().toString() + "-v2"); + sensor.setAcceleration(random.nextFloat() * 10); + sensor.setVelocity(random.nextFloat() * 100); + sensor.setInternalTemperature(random.nextFloat() * 50); + sensor.setExternalTemperature(random.nextFloat() * 50); + sensor.setAccelerometer(null); + sensor.setMagneticField(null); + return sensor; + } +} + diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/src/main/resources/application.yml b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/src/main/resources/application.yml new file mode 100644 index 0000000..24ea1a3 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/src/main/resources/application.yml @@ -0,0 +1,13 @@ +spring: + cloud: + stream: + bindings: + output: + contentType: application/*+avro + destination: sensor-topic + schema-registry-client: + endpoint: http://localhost:8990 + schema: + avro: + schema-locations: classpath:avro/sensor.avsc +server.port: 9010 \ No newline at end of file diff --git a/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/src/main/resources/avro/sensor.avsc b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/src/main/resources/avro/sensor.avsc new file mode 100644 index 0000000..8d2e605 --- /dev/null +++ b/schema-registry-samples/schema-registry-vanilla-rabbit-binder/schema-registry-vanilla-producer2-rabbit/src/main/resources/avro/sensor.avsc @@ -0,0 +1,25 @@ +{ + "namespace" : "com.example", + "type" : "record", + "name" : "Sensor", + "fields" : [ + {"name":"id","type":"string"}, + {"name":"internalTemperature", "type":"float", "default":0.0, "aliases":["temperature"]}, + {"name":"externalTemperature", "type":"float", "default":0.0}, + {"name":"acceleration", "type":"float","default":0.0}, + {"name":"velocity","type":"float","default":0.0}, + {"name":"accelerometer","type":[ + "null",{ + "type":"array", + "items":"float" + } + ]}, + {"name":"magneticField","type":[ + "null",{ + "type":"array", + "items":"float" + } + ]} + ] + +} \ No newline at end of file diff --git a/schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/pom.xml b/schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/pom.xml deleted file mode 100644 index 3bc5e23..0000000 --- a/schema-registry-samples/schema-registry-vanilla/kafka-streams-consumer/pom.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - 4.0.0 - - kafka-streams-consumer - 0.0.1-SNAPSHOT - jar - kafka-streams-consumer - Schema Registry Consumer - - - io.spring.cloud.stream.sample - spring-cloud-stream-samples-parent - 0.0.1-SNAPSHOT - ../../.. - - - - 1.8.2 - - - - - org.springframework.cloud - spring-cloud-stream-schema - - - org.apache.avro - avro - ${avro.version} - - - org.springframework.cloud - spring-cloud-stream-binder-kafka-streams - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.avro - avro-maven-plugin - ${avro.version} - - - generate-sources - - schema - protocol - idl-protocol - - - src/main/resources/avro - - - - - - - diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/pom.xml b/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/pom.xml deleted file mode 100644 index c01c688..0000000 --- a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-consumer/pom.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - 4.0.0 - - schema-registry-vanilla-consumer - 0.0.1-SNAPSHOT - jar - schema-registry-vanilla-consumer - Schema Registry Consumer - - - io.spring.cloud.stream.sample - spring-cloud-stream-samples-parent - 0.0.1-SNAPSHOT - ../../.. - - - - 1.8.2 - - - - - org.springframework.cloud - spring-cloud-stream-schema - - - org.apache.avro - avro - ${avro.version} - - - - - - kafka-binder - - true - - - - org.springframework.cloud - spring-cloud-stream-binder-kafka - - - - - - org.springframework.boot - spring-boot-maven-plugin - - kafka - - - - - - - rabbit-binder - - - org.springframework.cloud - spring-cloud-stream-binder-rabbit - - - - - - org.springframework.boot - spring-boot-maven-plugin - - rabbit - - - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.avro - avro-maven-plugin - ${avro.version} - - - generate-sources - - schema - protocol - idl-protocol - - - src/main/resources/avro - - - - - - - diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/pom.xml b/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/pom.xml deleted file mode 100644 index 968e9c8..0000000 --- a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/pom.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - 4.0.0 - - schema-registry-vanilla-producer1 - 0.0.1-SNAPSHOT - jar - schema-registry-vanilla-producer1 - Schema Registry Producer1 - - - io.spring.cloud.stream.sample - spring-cloud-stream-samples-parent - 0.0.1-SNAPSHOT - ../../.. - - - - 1.8.2 - - - - - org.springframework.cloud - spring-cloud-stream-schema - - - org.apache.avro - avro - ${avro.version} - - - - - - kafka-binder - - true - - - - org.springframework.cloud - spring-cloud-stream-binder-kafka - - - - - - org.springframework.boot - spring-boot-maven-plugin - - kafka - - - - - - - rabbit-binder - - - org.springframework.cloud - spring-cloud-stream-binder-rabbit - - - - - - org.springframework.boot - spring-boot-maven-plugin - - rabbit - - - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.avro - avro-maven-plugin - ${avro.version} - - - generate-sources - - schema - protocol - idl-protocol - - - src/main/resources/avro - - - - - - - diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/src/main/java/sample/producer2/Producer1Application.java b/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/src/main/java/sample/producer2/Producer1Application.java deleted file mode 100644 index 33b9a5e..0000000 --- a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer1/src/main/java/sample/producer2/Producer1Application.java +++ /dev/null @@ -1,62 +0,0 @@ -package sample.producer2; - -import com.example.Sensor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.messaging.Source; -import org.springframework.cloud.stream.schema.client.EnableSchemaRegistryClient; -import org.springframework.messaging.support.MessageBuilder; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Random; -import java.util.UUID; - -@SpringBootApplication -@EnableSchemaRegistryClient -@EnableBinding(Source.class) -@RestController -public class Producer1Application { - - @Autowired - private Source source; - - private Random random = new Random(); - - public static void main(String[] args) { - SpringApplication.run(Producer1Application.class, args); - } - - @RequestMapping(value = "/messages", method = RequestMethod.POST) - public String sendMessage() { - source.output().send(MessageBuilder.withPayload(randomSensor()).build()); - return "ok, have fun with v1 payload!"; - } - - private Sensor randomSensor() { - Sensor sensor = new Sensor(); - sensor.setId(UUID.randomUUID().toString() + "-v1"); - sensor.setAcceleration(random.nextFloat() * 10); - sensor.setVelocity(random.nextFloat() * 100); - sensor.setTemperature(random.nextFloat() * 50); - return sensor; - } - - //Another convenience POST method for testing deterministic values - @RequestMapping(value = "/messagesX", method = RequestMethod.POST) - public String sendMessageX(@RequestParam(value="id") String id, @RequestParam(value="acceleration") float acceleartion, - @RequestParam(value="velocity") float velocity, @RequestParam(value="temperature") float temperature) { - Sensor sensor = new Sensor(); - sensor.setId(id + "-v1"); - sensor.setAcceleration(acceleartion); - sensor.setVelocity(velocity); - sensor.setTemperature(temperature); - source.output().send(MessageBuilder.withPayload(sensor).build()); - return "ok, have fun with v1 payload!"; - } -} - diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/pom.xml b/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/pom.xml deleted file mode 100644 index dc7a613..0000000 --- a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/pom.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - 4.0.0 - - schema-registry-vanilla-producer2 - 0.0.1-SNAPSHOT - jar - schema-registry-vanilla-producer2 - Schema Registry Producer2 - - - io.spring.cloud.stream.sample - spring-cloud-stream-samples-parent - 0.0.1-SNAPSHOT - ../../.. - - - - 1.8.2 - - - - - org.springframework.cloud - spring-cloud-stream-schema - - - org.apache.avro - avro - ${avro.version} - - - - - - kafka-binder - - true - - - - org.springframework.cloud - spring-cloud-stream-binder-kafka - - - - - - org.springframework.boot - spring-boot-maven-plugin - - kafka - - - - - - - rabbit-binder - - - org.springframework.cloud - spring-cloud-stream-binder-rabbit - - - - - - org.springframework.boot - spring-boot-maven-plugin - - rabbit - - - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.avro - avro-maven-plugin - ${avro.version} - - - generate-sources - - schema - protocol - idl-protocol - - - src/main/resources/avro - - - - - - - diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/src/main/java/sample/producer2/Producer2Application.java b/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/src/main/java/sample/producer2/Producer2Application.java deleted file mode 100644 index fb868c4..0000000 --- a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-producer2/src/main/java/sample/producer2/Producer2Application.java +++ /dev/null @@ -1,64 +0,0 @@ -package sample.producer2; - -import com.example.Sensor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.stream.annotation.EnableBinding; -import org.springframework.cloud.stream.messaging.Source; -import org.springframework.cloud.stream.schema.client.EnableSchemaRegistryClient; -import org.springframework.messaging.support.MessageBuilder; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Random; -import java.util.UUID; - -@SpringBootApplication -@EnableSchemaRegistryClient -@EnableBinding(Source.class) -@RestController -public class Producer2Application { - - @Autowired - private Source source; - - private Random random = new Random(); - - public static void main(String[] args) { - SpringApplication.run(Producer2Application.class, args); - } - - @RequestMapping(value = "/messages", method = RequestMethod.POST) - public String sendMessage() { - source.output().send(MessageBuilder.withPayload(randomSensor()).build()); - return "ok, have fun with v2 payload!"; - } - - private Sensor randomSensor() { - Sensor sensor = new Sensor(); - sensor.setId(UUID.randomUUID().toString() + "-v2"); - sensor.setAcceleration(random.nextFloat() * 10); - sensor.setVelocity(random.nextFloat() * 100); - sensor.setInternalTemperature(random.nextFloat() * 50); - sensor.setAccelerometer(null); - sensor.setMagneticField(null); - return sensor; - } - - //Another convenience POST method for testing deterministic values - @RequestMapping(value = "/messagesX", method = RequestMethod.POST) - public String sendMessageX(@RequestParam(value="id") String id, @RequestParam(value="acceleration") float acceleartion, - @RequestParam(value="velocity") float velocity, @RequestParam(value="temperature") float temperature) { - Sensor sensor = new Sensor(); - sensor.setId(id + "-v2"); - sensor.setAcceleration(acceleartion); - sensor.setVelocity(velocity); - sensor.setInternalTemperature(temperature); - source.output().send(MessageBuilder.withPayload(sensor).build()); - return "ok, have fun with v2 payload!"; - } -} - diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/.gitignore b/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/.gitignore deleted file mode 100644 index 2af7cef..0000000 --- a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -target/ -!.mvn/wrapper/maven-wrapper.jar - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -nbproject/private/ -build/ -nbbuild/ -dist/ -nbdist/ -.nb-gradle/ \ No newline at end of file diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/.mvn/wrapper/maven-wrapper.jar b/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index 9cc84ea..0000000 Binary files a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/.mvn/wrapper/maven-wrapper.properties b/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index b573bb5..0000000 --- a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1 +0,0 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/pom.xml b/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/pom.xml deleted file mode 100644 index 508ad4f..0000000 --- a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - 4.0.0 - - schema-registry-vanilla-server - 0.0.1-SNAPSHOT - jar - schema-registry-vanilla-server - Schema Registry for sample - - - io.spring.cloud.stream.sample - spring-cloud-stream-samples-parent - 0.0.1-SNAPSHOT - ../../.. - - - - - org.springframework.cloud - spring-cloud-stream-schema-server - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/src/main/java/com/example/registry/RegistryApplication.java b/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/src/main/java/com/example/registry/RegistryApplication.java deleted file mode 100644 index f082c78..0000000 --- a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/src/main/java/com/example/registry/RegistryApplication.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.example.registry; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.stream.schema.server.EnableSchemaRegistryServer; - -@SpringBootApplication -@EnableSchemaRegistryServer -public class RegistryApplication { - - public static void main(String[] args) { - SpringApplication.run(RegistryApplication.class, args); - } -} diff --git a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/src/main/resources/application.properties b/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/src/main/resources/application.properties deleted file mode 100644 index ad1a7e4..0000000 --- a/schema-registry-samples/schema-registry-vanilla/schema-registry-vanilla-server/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -management.security.enabled=false \ No newline at end of file