Skip to content

Commit 0e5fafd

Browse files
authored
We need to enable headers so that the bean type is sent for each kafka message (#6022)
1 parent 2aa24b9 commit 0e5fafd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

examples/simple-json/src/main/java/io/apicurio/registry/examples/simple/json/SimpleJsonSchemaExample.java

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io.apicurio.registry.rest.client.models.IfArtifactExists;
2323
import io.apicurio.registry.rest.client.models.VersionContent;
2424
import io.apicurio.registry.rest.client.models.VersionMetaData;
25+
import io.apicurio.registry.serde.config.KafkaSerdeConfig;
2526
import io.apicurio.registry.serde.config.SerdeConfig;
2627
import io.apicurio.registry.serde.jsonschema.JsonSchemaKafkaDeserializer;
2728
import io.apicurio.registry.serde.jsonschema.JsonSchemaKafkaSerializer;
@@ -184,6 +185,8 @@ private static Producer<Object, Object> createKafkaProducer() {
184185
// Use the Apicurio Registry provided Kafka Serializer for JSON Schema
185186
props.putIfAbsent(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
186187
JsonSchemaKafkaSerializer.class.getName());
188+
// Send metadata in message headers (includes the schema coordinates and the message bean type)
189+
props.putIfAbsent(KafkaSerdeConfig.ENABLE_HEADERS, true);
187190

188191
// Configure Service Registry location
189192
props.putIfAbsent(SerdeConfig.REGISTRY_URL, REGISTRY_URL);
@@ -215,6 +218,8 @@ private static KafkaConsumer<Long, MessageBean> createKafkaConsumer() {
215218
// Use the Apicurio Registry provided Kafka Deserializer for JSON Schema
216219
props.putIfAbsent(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
217220
JsonSchemaKafkaDeserializer.class.getName());
221+
// Read metadata from message headers (includes the schema coordinates and the message bean type)
222+
props.putIfAbsent(KafkaSerdeConfig.ENABLE_HEADERS, true);
218223

219224
// Configure Service Registry location
220225
props.putIfAbsent(SerdeConfig.REGISTRY_URL, REGISTRY_URL);

0 commit comments

Comments
 (0)