Skip to content

Commit 349246b

Browse files
author
Michael Bridgen
committed
Change name of variations on noAck in examples too
1 parent b4ce3b1 commit 349246b

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ public static void main(String[] args) {
6868
final String hostName = optArg(args, 0, "localhost");
6969
final int portNumber = optArg(args, 1, AMQP.PROTOCOL.PORT);
7070
boolean writeStats = optArg(args, 2, true);
71-
boolean noAck = optArg(args, 3, true);
71+
boolean autoAck = optArg(args, 3, true);
7272
final Connection conn = new ConnectionFactory(){{setHost(hostName); setPort(portNumber);}}.newConnection();
7373
System.out.println("Channel 0 fully open.");
74-
new ConsumerMain(conn, writeStats, noAck).run();
74+
new ConsumerMain(conn, writeStats, autoAck).run();
7575
} catch (Exception e) {
7676
System.err.println("Main thread caught exception: " + e);
7777
e.printStackTrace();
@@ -91,14 +91,14 @@ public static void sleep(int ms) {
9191

9292
public boolean _writeStats;
9393

94-
public boolean _noAck;
94+
public boolean _autoAck;
9595

96-
public ConsumerMain(Connection connection, boolean writeStats, boolean noAck) {
96+
public ConsumerMain(Connection connection, boolean writeStats, boolean autoAck) {
9797
_connection = connection;
9898
_writeStats = writeStats;
99-
_noAck = noAck;
99+
_autoAck = autoAck;
100100
System.out.println((_writeStats ? "WILL" : "WON'T") + " write statistics.");
101-
System.out.println((_noAck ? "WILL" : "WON'T") + " use server-side auto-acking.");
101+
System.out.println((_autoAck ? "WILL" : "WON'T") + " use server-side auto-acking.");
102102
}
103103

104104
public void run() {
@@ -124,9 +124,9 @@ private void runIt() throws IOException {
124124
channel.queueBind(completionQueue, exchangeName, "");
125125

126126
LatencyExperimentConsumer callback = new LatencyExperimentConsumer(channel, queueName);
127-
callback._noAck = this._noAck;
127+
callback._autoAck = this._autoAck;
128128

129-
channel.basicConsume(queueName, _noAck, callback);
129+
channel.basicConsume(queueName, _autoAck, callback);
130130
channel.basicConsume(completionQueue, true, "completion", callback);
131131
callback.report(_writeStats);
132132

@@ -165,7 +165,7 @@ public static class LatencyExperimentConsumer extends DefaultConsumer {
165165

166166
public long _nextSummaryTime;
167167

168-
public boolean _noAck = true;
168+
public boolean _autoAck = true;
169169

170170
public LatencyExperimentConsumer(Channel ch, String queueName) {
171171
super(ch);
@@ -277,7 +277,7 @@ public void report(boolean writeStats) throws IOException {
277277
if (msgStartTime != -1) {
278278
_deltas[_received++] = now - msgStartTime;
279279

280-
if (!_noAck && ((_received % ACK_BATCH_SIZE) == 0)) {
280+
if (!_autoAck && ((_received % ACK_BATCH_SIZE) == 0)) {
281281
getChannel().basicAck(0, true);
282282
}
283283
}
@@ -293,7 +293,7 @@ public void report(boolean writeStats) throws IOException {
293293
}
294294

295295
public void finish() throws IOException {
296-
if (!_noAck)
296+
if (!_autoAck)
297297
getChannel().basicAck(0, true);
298298
_blocker.setIfUnset(new Object());
299299
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,27 +323,27 @@ public TracingConsumer(Channel ch) {
323323
}
324324

325325
public class BatchedTracingConsumer extends TracingConsumer {
326-
final boolean _noAck;
326+
final boolean _autoAck;
327327

328328
final BlockingCell<Object> _k;
329329

330330
final int _batchSize;
331331

332332
int _counter;
333333

334-
public BatchedTracingConsumer(boolean noAck, BlockingCell<Object> k, int batchSize, Channel ch) {
334+
public BatchedTracingConsumer(boolean autoAck, BlockingCell<Object> k, int batchSize, Channel ch) {
335335
super(ch);
336-
_noAck = noAck;
336+
_autoAck = autoAck;
337337
_k = k;
338338
_batchSize = batchSize;
339339
_counter = 0;
340340
}
341341

342342
@Override public void handleDelivery(String consumer_Tag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
343-
log("Async message (" + _counter + "," + (_noAck ? "noack" : "ack") + "): " + new String(body));
343+
log("Async message (" + _counter + "," + (_autoAck ? "autoack" : "ack") + "): " + new String(body));
344344
_counter++;
345345
if (_counter == _batchSize) {
346-
if (!_noAck) {
346+
if (!_autoAck) {
347347
log("Acking batch.");
348348
getChannel().basicAck(envelope.getDeliveryTag(), true);
349349
}
@@ -379,15 +379,15 @@ public void assertNonNull(Object o) {
379379
}
380380
}
381381

382-
public int drain(int batchSize, String queueName, boolean noAck) throws IOException {
382+
public int drain(int batchSize, String queueName, boolean autoAck) throws IOException {
383383
long latestTag = 0;
384384
boolean notEmpty = true;
385385
int remaining = batchSize;
386386
int count = 0;
387387

388388
while (notEmpty && (remaining > 0)) {
389389
for (int i = 0; (i < 2) && (remaining > 0); i++) {
390-
GetResponse c = _ch1.basicGet(queueName, noAck);
390+
GetResponse c = _ch1.basicGet(queueName, autoAck);
391391
if (c == null) {
392392
notEmpty = false;
393393
} else {
@@ -398,7 +398,7 @@ public int drain(int batchSize, String queueName, boolean noAck) throws IOExcept
398398
count++;
399399
}
400400
}
401-
if (!noAck && latestTag != 0) {
401+
if (!autoAck && latestTag != 0) {
402402
_ch1.basicAck(latestTag, true);
403403
latestTag = 0;
404404
}

0 commit comments

Comments
 (0)