You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "philipnee (via GitHub)" <gi...@apache.org> on 2023/02/14 16:20:21 UTC

[GitHub] [kafka] philipnee commented on a diff in pull request #13238: KAFKA-14708: Use Java thread instead of kafka library for example purpose

philipnee commented on code in PR #13238:
URL: https://github.com/apache/kafka/pull/13238#discussion_r1106052765


##########
examples/src/main/java/kafka/examples/Consumer.java:
##########
@@ -63,33 +63,36 @@ public Consumer(final String topic,
         this.numMessageToConsume = numMessageToConsume;
         this.messageRemaining = numMessageToConsume;
         this.latch = latch;
+        this.isRunning = true;
     }
 
     KafkaConsumer<Integer, String> get() {
         return consumer;
     }
 
     @Override
+    public void run() {
+        try {
+            do {
+                doWork();
+            } while (isRunning && messageRemaining > 0);
+            System.out.println(groupId + " finished reading " + numMessageToConsume + " messages");
+        } catch (Exception ignored) {

Review Comment:
   Hmm good point, I'll add a log there. 



-- 
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: jira-unsubscribe@kafka.apache.org

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