Springify: Nachrichten-Typ wird über den Type-Info-Header bestimmt
authorKai Moritz <kai@juplo.de>
Sun, 17 Apr 2022 11:44:49 +0000 (13:44 +0200)
committerKai Moritz <kai@juplo.de>
Mon, 18 Apr 2022 11:42:01 +0000 (13:42 +0200)
src/main/java/de/juplo/kafka/ApplicationConfiguration.java
src/test/java/de/juplo/kafka/ApplicationTests.java

index 566c7a3..431041c 100644 (file)
@@ -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);
index fbc668f..6c25bcd 100644 (file)
@@ -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)