package com.alibaba.rocketmq.example.concurrent;

import com.alibaba.rocketmq.client.producer.SendCallback;
import com.alibaba.rocketmq.client.producer.SendResult;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.atomic.AtomicLong;

public class ExampleSendCallback implements SendCallback {

    private AtomicLong successfulSentCounter;

    private long total;

    private long start;

    private long previousStatsTime;

    public ExampleSendCallback(AtomicLong successfulSentCounter, long total, long startTime) {
        this.successfulSentCounter = successfulSentCounter;
        this.total = total;
        this.start = startTime;
        previousStatsTime = startTime;
    }

    @Override
    public void onSuccess(SendResult sendResult) {
        successfulSentCounter.incrementAndGet();

        if (successfulSentCounter.longValue() % 10000 == 0) {
            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            System.out.println(dateFormat.format(new Date()) + " TPS:" + successfulSentCounter.longValue() * 1000 / (System.currentTimeMillis() - previousStatsTime));
            previousStatsTime = System.currentTimeMillis();
        }


        //System.out.println("ExampleSendCallback#onSuccess:" + successfulSentCounter.incrementAndGet() + " sent OK. " + sendResult);
        if (successfulSentCounter.longValue() >= total) {
            long interval = System.currentTimeMillis() - start;
            System.out.println("All Messages Sent Successfully in " + interval + "ms. Average TPS:" + (total * 1000L / interval));
        }
    }

    @Override
    public void onException(Throwable e) {
        System.out.println("Failure occurred. Now " + successfulSentCounter.longValue() + " sent OK.");
        e.printStackTrace();
    }
}

@@ -487,16 +487,72 @@
 sTime;%0A%0A
+    private static final long COUNT_INTERVAL = 1000L;%0A%0A%0A
     publ
@@ -971,13 +971,22 @@
 ) %25 
-10000
+COUNT_INTERVAL
  == 
@@ -1148,41 +1148,22 @@
 %22 + 
-successfulSentCounter.longValue()
+COUNT_INTERVAL
  * 1

Fix example.