Skip to content

Commit 954daba

Browse files
author
Alexandru Scvortov
committed
MCM: confirm stats only printed if in confirm mode
1 parent 0aa5c06 commit 954daba

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

test/src/com/rabbitmq/examples/MulticastMain.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public static void main(String[] args) {
147147
flags, producerTxSize,
148148
1000L * samplingInterval,
149149
rateLimit, minMsgSize, timeLimit,
150-
confirmMax);
150+
confirm, confirmMax);
151151
channel.setReturnListener(p);
152152
channel.setAckListener(p);
153153
Thread t = new Thread(p);
@@ -244,14 +244,15 @@ public static class Producer implements Runnable, ReturnListener, AckListener {
244244
private int msgCount;
245245
private int basicReturnCount;
246246

247+
private boolean confirm;
247248
private long confirmMax;
248249
private long mostRecentConfirmed;
249250
private long confirmCount;
250251

251252
public Producer(Channel channel, String exchangeName, String id,
252253
List flags, int txSize,
253254
long interval, int rateLimit, int minMsgSize, int timeLimit,
254-
long confirmMax)
255+
boolean confirm, long confirmMax)
255256
throws IOException {
256257

257258
this.channel = channel;
@@ -266,6 +267,7 @@ public Producer(Channel channel, String exchangeName, String id,
266267
this.timeLimit = 1000L * timeLimit;
267268
this.confirmMax = confirmMax;
268269
this.message = new byte[minMsgSize];
270+
this.confirm = confirm;
269271
}
270272

271273
public void handleBasicReturn(int replyCode,
@@ -362,15 +364,18 @@ private void delay(long now)
362364
Thread.sleep(pause);
363365
}
364366
if (elapsed > interval) {
365-
System.out.println("sending rate: " +
366-
(msgCount * 1000L / elapsed) +
367-
" msg/s" +
368-
", basic returns: " +
369-
(basicReturnCount * 1000L / elapsed) +
370-
" ret/s" +
371-
", confirms: " +
372-
(confirmCount * 1000L / elapsed) +
373-
" c/s");
367+
System.out.print("sending rate: " +
368+
(msgCount * 1000L / elapsed) +
369+
" msg/s");
370+
System.out.print(", basic returns: " +
371+
(basicReturnCount * 1000L / elapsed) +
372+
" ret/s");
373+
if (confirm) {
374+
System.out.print(", confirms: " +
375+
(confirmCount * 1000L / elapsed) +
376+
" c/s");
377+
}
378+
System.out.println();
374379
resetBasicReturns();
375380
resetConfirms();
376381
msgCount = 0;

0 commit comments

Comments
 (0)