apalan60 commented on code in PR #20524:
URL: https://github.com/apache/kafka/pull/20524#discussion_r2342035611


##########
clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerTest.java:
##########
@@ -217,6 +231,33 @@ var record = new ProducerRecord<>(TP.topic(), 
TP.partition(), null, "key".getByt
         }
     }
 
+    private void testHeadersOrderPreserved(Map<String, Object> consumerConfig) 
throws Exception {
+        var numRecords = 1;
+
+        try (Producer<byte[], byte[]> producer = cluster.producer();
+             Consumer<byte[], byte[]> consumer = 
cluster.consumer(consumerConfig)
+        ) {
+            var record = new ProducerRecord<>(TP.topic(), TP.partition(), 
null, "key".getBytes(), "value".getBytes());
+            record.headers().add("headerKey", "headerValue".getBytes());
+            record.headers().add("headerKey2", "headerValue2".getBytes());
+            record.headers().add("headerKey3", "headerValue3".getBytes());
+            producer.send(record);
+
+            assertEquals(0, consumer.assignment().size());
+            consumer.assign(List.of(TP));
+            assertEquals(1, consumer.assignment().size());
+
+            consumer.seek(TP, 0);
+            var records = consumeRecords(consumer, numRecords);
+            assertEquals(numRecords, records.size());

Review Comment:
   nit: the current approach works fine since `consumeRecords` waits until the 
record arrives.
   Just wondering if adding `producer.flush()` might make the intent slightly 
clearer?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to