@@ -242,7 +242,7 @@ public static class Producer implements Runnable, ReturnListener, AckListener {
242242 private long startTime ;
243243 private long lastStatsTime ;
244244 private int msgCount ;
245- private int basicReturnCount ;
245+ private int returnCount ;
246246
247247 private boolean confirm ;
248248 private long confirmMax ;
@@ -270,33 +270,25 @@ public Producer(Channel channel, String exchangeName, String id,
270270 this .confirm = confirm ;
271271 }
272272
273- public void handleBasicReturn (int replyCode ,
274- String replyText ,
275- String exchange ,
276- String routingKey ,
277- AMQP .BasicProperties properties ,
278- byte [] body ) throws IOException {
279- logBasicReturn ();
280- }
281-
282- public synchronized void logBasicReturn () {
283- basicReturnCount ++;
284- }
285-
286- public synchronized void resetBasicReturns () {
287- basicReturnCount = 0 ;
288- }
289-
290- public void handleAck (long sequenceNumber , boolean multiple ) {
291- logAck (sequenceNumber );
273+ public synchronized void handleBasicReturn (int replyCode ,
274+ String replyText ,
275+ String exchange ,
276+ String routingKey ,
277+ AMQP .BasicProperties properties ,
278+ byte [] body )
279+ throws IOException {
280+ returnCount ++;
292281 }
293282
294- private synchronized void resetConfirms () {
283+ public synchronized void resetCounts () {
284+ msgCount = 0 ;
285+ returnCount = 0 ;
295286 confirmCount = 0 ;
296287 }
297288
298- private synchronized void logAck (long seqNum ) {
299- mostRecentConfirmed = seqNum ;
289+ public synchronized void handleAck (long sequenceNumber ,
290+ boolean multiple ) {
291+ mostRecentConfirmed = sequenceNumber ;
300292 confirmCount ++;
301293 }
302294
@@ -368,8 +360,8 @@ private void delay(long now)
368360 (msgCount * 1000L / elapsed ) +
369361 " msg/s" );
370362 if (mandatory || immediate ) {
371- System .out .print (", basic returns: " +
372- (basicReturnCount * 1000L / elapsed ) +
363+ System .out .print (", returns: " +
364+ (returnCount * 1000L / elapsed ) +
373365 " ret/s" );
374366 }
375367 if (confirm ) {
@@ -378,9 +370,7 @@ private void delay(long now)
378370 " c/s" );
379371 }
380372 System .out .println ();
381- resetBasicReturns ();
382- resetConfirms ();
383- msgCount = 0 ;
373+ resetCounts ();
384374 lastStatsTime = now ;
385375 }
386376 }
0 commit comments