gwenshap commented on a change in pull request #9815:
URL: https://github.com/apache/kafka/pull/9815#discussion_r553705175



##########
File path: examples/src/main/java/kafka/examples/Consumer.java
##########
@@ -62,34 +62,24 @@ public Consumer(final String topic,
         this.topic = topic;
         this.numMessageToConsume = numMessageToConsume;
         this.messageRemaining = numMessageToConsume;
-        this.latch = latch;
     }
 
     KafkaConsumer<Integer, String> get() {
         return consumer;
     }
 
     @Override
-    public void doWork() {
+    public void run() {
         consumer.subscribe(Collections.singletonList(this.topic));
-        ConsumerRecords<Integer, String> records = 
consumer.poll(Duration.ofSeconds(1));
-        for (ConsumerRecord<Integer, String> record : records) {
-            System.out.println(groupId + " received message : from partition " 
+ record.partition() + ", (" + record.key() + ", " + record.value() + ") at 
offset " + record.offset());
+        while (!Thread.currentThread().isInterrupted() &&  messageRemaining > 
0) {

Review comment:
       I believe so... 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to