Skip to content

Commit c4f0019

Browse files
committed
merge bug19551 into default
2 parents 1713c30 + c3dd63b commit c4f0019

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

test/src/com/rabbitmq/client/test/functional/DurableOnTransient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public void testBind()
8484
B = true;
8585
}
8686
channel.queueDelete(ticket, Q);
87+
channel.exchangeDelete(ticket, X);
8788

8889
assertTrue(B);
8990

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private void runIt() throws IOException {
108108
channel.queueDeclare(ticket, queueName);
109109

110110
String exchangeName = "test completion";
111-
channel.exchangeDeclare(ticket, exchangeName, "fanout");
111+
channel.exchangeDeclare(ticket, exchangeName, "fanout", false, false, true, null);
112112

113113
String completionQueue = channel.queueDeclare(ticket).getQueue();
114114
channel.queueBind(ticket, completionQueue, exchangeName, "");

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,22 @@ private void runIt() throws IOException {
148148

149149
String queueName = "test queue";
150150
_channel.queueDeclare(_ticket, queueName, shouldPersist());
151-
152-
String exchangeName = "test completion";
153-
_channel.exchangeDeclare(_ticket, exchangeName, "fanout");
154-
151+
155152
if (shouldCommit()) {
156153
_channel.txSelect();
157154
}
158155
sendBatch(queueName);
159156

160157
if (_sendCompletion) {
158+
// Declaring this exchange as auto-delete is a bit dodgy because of a
159+
// race condition with the consumer declaring the same exchange to be
160+
// auto-delete and hence pulling the rug out from underneath the producer's
161+
// feet.
162+
// Hence we're delaying a possible re-declaration until as late as possible.
163+
// Ideally you would use a global lock around both critical sections,
164+
// but thread safety has gone out of fashion these days.
165+
String exchangeName = "test completion";
166+
_channel.exchangeDeclare(_ticket, exchangeName, "fanout", false, false, true, null);
161167
_channel.basicPublish(_ticket, exchangeName, "", MessageProperties.BASIC, new byte[0]);
162168
if (shouldCommit())
163169
_channel.txCommit();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ public void tryBasicReturn() throws IOException {
458458
log("About to try mandatory/immediate publications");
459459

460460
String mx = "mandatoryTestExchange";
461-
_ch1.exchangeDeclare(_ticket, mx, "fanout");
461+
_ch1.exchangeDeclare(_ticket, mx, "fanout", false, false, true, null);
462462

463463
returnCell = new BlockingCell<Object>();
464464
_ch1.basicPublish(_ticket, mx, "", true, false, null, "one".getBytes());

0 commit comments

Comments
 (0)