Cleaning up the kafka native serialization sample

This commit is contained in:
Soby Chacko
2020-01-09 18:34:55 -05:00
parent 85551b3376
commit eb63558b79
3 changed files with 2 additions and 21 deletions

View File

@@ -1,19 +0,0 @@
package com.example.kafkanativeserialization;
import org.apache.kafka.common.header.Headers;
import org.springframework.kafka.support.serializer.JsonSerializer;
import org.springframework.lang.Nullable;
public class MyJsonSerializer extends JsonSerializer<Object> {
@Override
@Nullable
public byte[] serialize(String topic, Headers headers, @Nullable Object data) {
return super.serialize(topic, headers, data);
}
@Override
@Nullable
public byte[] serialize(String topic, @Nullable Object data) {
return super.serialize(topic, data);
}
}

View File

@@ -14,4 +14,4 @@ spring.cloud:
process-out-0:
producer:
configuration:
value.serializer: com.example.kafkanativeserialization.MyJsonSerializer
value.serializer: org.springframework.kafka.support.serializer.JsonSerializer

View File

@@ -54,7 +54,7 @@ public class KafkaNativeSerializationApplicationTests {
Consumer<byte[], Person> consumer = cf.createConsumer();
consumer.subscribe(Collections.singleton(OUTPUT_TOPIC));
ConsumerRecords<byte[], Person> records = consumer.poll(Duration.ofSeconds(5));
ConsumerRecords<byte[], Person> records = consumer.poll(Duration.ofSeconds(10));
consumer.commitSync();
assertThat(records.count()).isEqualTo(1);