diff --git a/kafka-native-serialization/README.adoc b/kafka-native-serialization/README.adoc new file mode 100644 index 0000000..7a2d5d0 --- /dev/null +++ b/kafka-native-serialization/README.adoc @@ -0,0 +1,19 @@ +Spring Cloud Stream Kafka and native encoding +============================================== + +In this *Spring Cloud Stream* sample, we demonstrate native encoding with Kafka and functions. +Spring Cloud Stream will skip the regular message conversion and on the outbound and let Kafka natively perform serialization. + +## Requirements + +To run this sample, you will need to have installed: + +* Java 8 or Above + +## Code Tour + +There is a test provided where we verify the native conversion done by Kafka. This test uses `EmbeddedKafka`. +You can also run the application against a real Kafka cluster to see it in action. + + + diff --git a/kafka-native-serialization/pom.xml b/kafka-native-serialization/pom.xml index cfc9509..b01886d 100644 --- a/kafka-native-serialization/pom.xml +++ b/kafka-native-serialization/pom.xml @@ -16,7 +16,7 @@ 1.8 - Hoxton.BUILD-SNAPSHOT + Horsham.BUILD-SNAPSHOT @@ -57,8 +57,8 @@ org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} + spring-cloud-stream-dependencies + ${spring-cloud-stream.version} pom import diff --git a/kafka-native-serialization/src/main/java/com/example/kafkanativeserialization/KafkaNativeSerializationApplication.java b/kafka-native-serialization/src/main/java/com/example/kafkanativeserialization/KafkaNativeSerializationApplication.java index 1d3ffa9..e072410 100644 --- a/kafka-native-serialization/src/main/java/com/example/kafkanativeserialization/KafkaNativeSerializationApplication.java +++ b/kafka-native-serialization/src/main/java/com/example/kafkanativeserialization/KafkaNativeSerializationApplication.java @@ -1,3 +1,19 @@ +/* + * Copyright 2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.example.kafkanativeserialization; import java.util.function.Function; diff --git a/kafka-native-serialization/src/main/java/com/example/kafkanativeserialization/MyJsonDeserializer.java b/kafka-native-serialization/src/main/java/com/example/kafkanativeserialization/MyJsonDeserializer.java deleted file mode 100644 index 4201f8e..0000000 --- a/kafka-native-serialization/src/main/java/com/example/kafkanativeserialization/MyJsonDeserializer.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.example.kafkanativeserialization; - -import org.springframework.kafka.support.serializer.JsonDeserializer; - -public class MyJsonDeserializer extends JsonDeserializer { -} diff --git a/kafka-native-serialization/src/main/java/com/example/kafkanativeserialization/Person.java b/kafka-native-serialization/src/main/java/com/example/kafkanativeserialization/Person.java index 2a50f44..63f3918 100644 --- a/kafka-native-serialization/src/main/java/com/example/kafkanativeserialization/Person.java +++ b/kafka-native-serialization/src/main/java/com/example/kafkanativeserialization/Person.java @@ -1,3 +1,19 @@ +/* + * Copyright 2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.example.kafkanativeserialization; public class Person { diff --git a/kafka-native-serialization/src/test/java/com/example/kafkanativeserialization/KafkaNativeSerializationApplicationTests.java b/kafka-native-serialization/src/test/java/com/example/kafkanativeserialization/KafkaNativeSerializationApplicationTests.java index 2e00b64..0212eca 100644 --- a/kafka-native-serialization/src/test/java/com/example/kafkanativeserialization/KafkaNativeSerializationApplicationTests.java +++ b/kafka-native-serialization/src/test/java/com/example/kafkanativeserialization/KafkaNativeSerializationApplicationTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.example.kafkanativeserialization; import java.time.Duration; diff --git a/kafka-native-serialization/src/test/java/com/example/kafkanativeserialization/MyJsonDeserializer.java b/kafka-native-serialization/src/test/java/com/example/kafkanativeserialization/MyJsonDeserializer.java new file mode 100644 index 0000000..2f434d1 --- /dev/null +++ b/kafka-native-serialization/src/test/java/com/example/kafkanativeserialization/MyJsonDeserializer.java @@ -0,0 +1,22 @@ +/* + * Copyright 2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.kafkanativeserialization; + +import org.springframework.kafka.support.serializer.JsonDeserializer; + +public class MyJsonDeserializer extends JsonDeserializer { +}