"Fixed" the bug by adding a default-handler master default-handler-as-fix
authorKai Moritz <kai@juplo.de>
Mon, 6 Jun 2022 16:49:21 +0000 (18:49 +0200)
committerKai Moritz <kai@juplo.de>
Mon, 6 Jun 2022 16:49:21 +0000 (18:49 +0200)
* The default-handler is _NOT_ necessary, if the handler-methods only
  consume the message itself.
* This looks like a bug in the automatic configuration:
  * Without the addtional parameter of type `ConsumerRecordMetaData`, the
    automatically created resolvers are able to consume the payload.
  * After the addition of the `consumerRecordMetaData`-parameter, the
    automatically created resolvers are empty and fail to resolve the
    payload.
  * After the addition of the default-handler, the required resolvers
    are availabe again.

src/main/java/de/juplo/kafka/MultiMessageConsumer.java

index e6179e1..f0b12ef 100644 (file)
@@ -51,4 +51,17 @@ public class MultiMessageConsumer
         metadata.offset());
     bars.add(bar);
   }
+
+  @KafkaHandler(isDefault = true)
+  void handleUnknown(
+      @Payload Object unknown,
+      @Header(KafkaHeaders.RECORD_METADATA) ConsumerRecordMetadata metadata)
+  {
+    log.info(
+        "Received an unknown message: {}",
+        unknown,
+        metadata.topic(),
+        metadata.partition(),
+        metadata.offset());
+  }
 }