Further changes for the Kafka native serialization sample

This commit is contained in:
Soby Chacko
2020-01-10 16:25:10 -05:00
parent eb63558b79
commit 9a14238a50
7 changed files with 92 additions and 9 deletions

View File

@@ -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.

View File

@@ -16,7 +16,7 @@
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.BUILD-SNAPSHOT</spring-cloud.version>
<spring-cloud-stream.version>Horsham.BUILD-SNAPSHOT</spring-cloud-stream.version>
</properties>
<dependencies>
@@ -57,8 +57,8 @@
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<artifactId>spring-cloud-stream-dependencies</artifactId>
<version>${spring-cloud-stream.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

View File

@@ -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;

View File

@@ -1,6 +0,0 @@
package com.example.kafkanativeserialization;
import org.springframework.kafka.support.serializer.JsonDeserializer;
public class MyJsonDeserializer extends JsonDeserializer<Person> {
}

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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<Person> {
}