From: Kai Moritz Date: Sun, 17 Apr 2022 11:44:49 +0000 (+0200) Subject: Springify: Nachrichten-Typ wird über den Type-Info-Header bestimmt X-Git-Tag: sumup-adder---lvm-2-tage~9^2~7^2~6 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=c4fd031abdae00bdbd934216579f0a38ddd46783;p=demos%2Fkafka%2Ftraining Springify: Nachrichten-Typ wird über den Type-Info-Header bestimmt --- diff --git a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java index 566c7a3..431041c 100644 --- a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java +++ b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java @@ -62,7 +62,7 @@ public class ApplicationConfiguration props.put("metadata.max.age.ms", "1000"); props.put("key.deserializer", StringDeserializer.class.getName()); props.put("value.deserializer", JsonDeserializer.class.getName()); - props.put(JsonDeserializer.VALUE_DEFAULT_TYPE, ClientMessage.class.getName()); + props.put(JsonDeserializer.TYPE_MAPPINGS, "message:" + ClientMessage.class.getName()); props.put(JsonDeserializer.TRUSTED_PACKAGES, "de.juplo.kafka"); return new KafkaConsumer<>(props); diff --git a/src/test/java/de/juplo/kafka/ApplicationTests.java b/src/test/java/de/juplo/kafka/ApplicationTests.java index fbc668f..6c25bcd 100644 --- a/src/test/java/de/juplo/kafka/ApplicationTests.java +++ b/src/test/java/de/juplo/kafka/ApplicationTests.java @@ -203,6 +203,7 @@ class ApplicationTests Integer.toString(key%2), value); + record.headers().add("__TypeId__", "message".getBytes()); kafkaProducer.send(record, (metadata, e) -> { if (metadata != null)