Der Payload einer Nachricht wird über alle Nachrichten hochgezählt
authorKai Moritz <kai@juplo.de>
Sun, 15 Dec 2024 11:03:17 +0000 (12:03 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 15 Dec 2024 11:18:02 +0000 (12:18 +0100)
src/test/java/de/juplo/kafka/ExampleConsumerTest.java

index 65254e0..9b787ab 100644 (file)
@@ -148,6 +148,7 @@ public class ExampleConsumerTest
 
   LongSerializer serializer = new LongSerializer();
   long[] currentOffsets = new long[] { 0, 0 };
+  long nextMessage = 1;
 
   @Autowired
   AdminClient adminClient;
@@ -162,6 +163,7 @@ public class ExampleConsumerTest
     adminClient.deleteRecords(Map.of(
       new TopicPartition(TOPIC, 0), deleteAllRecordsByPartition(0),
       new TopicPartition(TOPIC, 1), deleteAllRecordsByPartition(1)));
+    nextMessage = 1;
     mockHandler.clear();
     isTerminatedExceptionally.set(false);
   }
@@ -173,7 +175,7 @@ public class ExampleConsumerTest
 
   private void sendValidMessage(int partition)
   {
-    send(partition, partition);
+    send(partition, nextMessage);
   }
 
   private void sendNonDeserializableMessage(int partition)
@@ -193,6 +195,7 @@ public class ExampleConsumerTest
 
   private void send(int partition, byte[] bytes)
   {
+    nextMessage++;
     kafkaTemplate.send(TOPIC, partition, "EGAL", bytes);
   }