Skip to content

Commit c061038

Browse files
committed
Bind to pre-declared queue for published-only test
Fixes #43
1 parent 0059157 commit c061038

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/main/java/com/rabbitmq/perf/MulticastParams.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public Consumer createConsumer(Connection connection, Stats stats, String id) th
266266
public boolean shouldConfigureQueues() {
267267
// don't declare any queues when --predeclared is passed,
268268
// otherwise unwanted server-named queues without consumers will pile up. MK.
269-
return consumerCount == 0 && !predeclared && !(queueNames.size() == 0);
269+
return consumerCount == 0 && !(queueNames.size() == 0);
270270
}
271271

272272
public List<String> configureQueues(Connection connection, String id) throws IOException {
@@ -275,7 +275,11 @@ public List<String> configureQueues(Connection connection, String id) throws IOE
275275
channel.exchangeDeclare(exchangeName, exchangeType);
276276
}
277277
// To ensure we get at-least 1 default queue:
278-
if (queueNames.isEmpty()) {
278+
// (don't declare any queues when --predeclared is passed,
279+
// otherwise unwanted server-named queues without consumers will pile up.
280+
// see https://github.com/rabbitmq/rabbitmq-perf-test/issues/25 and
281+
// https://github.com/rabbitmq/rabbitmq-perf-test/issues/43)
282+
if (!predeclared && queueNames.isEmpty()) {
279283
queueNames.add("");
280284
}
281285
List<String> generatedQueueNames = new ArrayList<String>();
@@ -288,7 +292,10 @@ public List<String> configureQueues(Connection connection, String id) throws IOE
288292
queueArguments).getQueue();
289293
}
290294
generatedQueueNames.add(qName);
291-
channel.queueBind(qName, exchangeName, id);
295+
// not allowed to bind to the default exchange
296+
if (!"".equals(exchangeName) && !"amq.default".equals(exchangeName)) {
297+
channel.queueBind(qName, exchangeName, id);
298+
}
292299
}
293300
channel.abort();
294301

src/main/java/com/rabbitmq/perf/PerfTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static void main(String[] args) {
5959
testID = strArg(cmd, 'd', "test-"+testID);
6060
String exchangeType = strArg(cmd, 't', "direct");
6161
String exchangeName = getExchangeName(cmd, exchangeType);
62-
String queueNames = strArg(cmd, 'u', "");
62+
String queueNames = strArg(cmd, 'u', null);
6363
String routingKey = strArg(cmd, 'k', null);
6464
boolean randomRoutingKey = cmd.hasOption('K');
6565
int samplingInterval = intArg(cmd, 'i', 1);
@@ -144,7 +144,7 @@ public static void main(String[] args) {
144144
p.setProducerChannelCount( producerChannelCount);
145145
p.setProducerMsgCount( producerMsgCount);
146146
p.setProducerTxSize( producerTxSize);
147-
p.setQueueNames( asList(queueNames.split(",")));
147+
p.setQueueNames( queueNames == null ? null : asList(queueNames.split(",")));
148148
p.setRoutingKey( routingKey);
149149
p.setRandomRoutingKey( randomRoutingKey);
150150
p.setProducerRateLimit( producerRateLimit);

0 commit comments

Comments
 (0)