kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From guozh...@apache.org
Subject kafka git commit: MINOR: ConsoleConsumer - Fix number of processed messages count
Date Thu, 03 Dec 2015 16:58:30 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk a5382a333 -> b09663eee


MINOR: ConsoleConsumer - Fix number of processed messages count

kafka-console-consumer.sh is showing an incorrect number of
messages processed, counting one more message than the actual
number of processed messages.

Author: Luciano Afranllie <luafran@gmail.com>

Reviewers: Guozhang Wang

Closes #617 from luafran/console-consumer-number-of-processed-messages


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/b09663ee
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/b09663ee
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/b09663ee

Branch: refs/heads/trunk
Commit: b09663eeec2153e2556983b8ef21551e69ee6afc
Parents: a5382a3
Author: Luciano Afranllie <luafran@gmail.com>
Authored: Thu Dec 3 08:58:24 2015 -0800
Committer: Guozhang Wang <wangguoz@gmail.com>
Committed: Thu Dec 3 08:58:24 2015 -0800

----------------------------------------------------------------------
 core/src/main/scala/kafka/tools/ConsoleConsumer.scala | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/b09663ee/core/src/main/scala/kafka/tools/ConsoleConsumer.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/tools/ConsoleConsumer.scala b/core/src/main/scala/kafka/tools/ConsoleConsumer.scala
index 2b9eb84..d560b72 100755
--- a/core/src/main/scala/kafka/tools/ConsoleConsumer.scala
+++ b/core/src/main/scala/kafka/tools/ConsoleConsumer.scala
@@ -105,7 +105,6 @@ object ConsoleConsumer extends Logging {
 
   def process(maxMessages: Integer, formatter: MessageFormatter, consumer: BaseConsumer,
skipMessageOnError: Boolean) {
     while (messageCount < maxMessages || maxMessages == -1) {
-      messageCount += 1
       val msg: BaseConsumerRecord = try {
         consumer.receive()
       } catch {
@@ -122,6 +121,7 @@ object ConsoleConsumer extends Logging {
           // Consumer will be closed
           return
       }
+      messageCount += 1
       try {
         formatter.writeTo(msg.key, msg.value, System.out)
       } catch {


Mime
View raw message