Skip to content

Commit b71e21e

Browse files
committed
Ensure queues are created with auto-delete and exclusive set to false
Since rabbitmq/rabbitmq-erlang-client#16, the `durable` parameter is honored (instead of being forced to true). So AMQP 1.0 queues are created as non-durable. In our Erlang AMQP client, this means the queue is created with auto-delete and exclusive set to true by default. We must explicitely set those to false. The testsuite is expanded to check that AMQP 0-9-1 queues created out-of-band can be properly used from AMQP 1.0, no matter their parameters. Fixes #22.
1 parent d55d005 commit b71e21e

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

deps/rabbitmq_amqp1_0/src/rabbit_amqp1_0_incoming_link.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ ensure_target(Target = #'v1_0.target'{address = Address,
193193
timeout = _Timeout},
194194
Link = #incoming_link{ route_state = RouteState }, DCh) ->
195195
DeclareParams = [{durable, rabbit_amqp1_0_link_util:durable(Durable)},
196+
{exclusive, false},
197+
{auto_delete, false},
196198
{check_exchange, true},
197199
{nowait, false}],
198200
case Dynamic of

deps/rabbitmq_amqp1_0/src/rabbit_amqp1_0_outgoing_link.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ ensure_source(Source = #'v1_0.source'{address = Address,
157157
timeout = _Timeout},
158158
Link = #outgoing_link{ route_state = RouteState }, DCh) ->
159159
DeclareParams = [{durable, rabbit_amqp1_0_link_util:durable(Durable)},
160+
{exclusive, false},
161+
{auto_delete, false},
160162
{check_exchange, true},
161163
{nowait, false}],
162164
case Dynamic of

deps/rabbitmq_amqp1_0/test/swiftmq/test/com/rabbitmq/amqp1_0/tests/swiftmq/SwiftMQTests.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,28 @@ public void testRouting() throws Exception {
226226
route("/exchange/amq.direct/", "/exchange/amq.direct", "", true);
227227
route("/exchange/amq.direct/a", "/exchange/amq.direct", "a", true);
228228

229+
/* The following three tests rely on the queue "test" created by
230+
* previous tests in this function. */
229231
route("/amq/queue/test", QUEUE, "", true);
230232
route(QUEUE, "/amq/queue/test", "", true);
231233
route("/amq/queue/test", "/amq/queue/test", "", true);
232234

235+
/* The following tests verify that a queue created out-of-band in AMQP
236+
* is reachable from the AMQP 1.0 world. */
237+
ConnectionFactory factory = new ConnectionFactory();
238+
com.rabbitmq.client.Connection connection = factory.newConnection();
239+
Channel channel = connection.createChannel();
240+
channel.queueDeclare("transient_q", false, false, false, null);
241+
route("/amq/queue/transient_q", "/amq/queue/transient_q", "", true);
242+
channel.queueDelete("transient_q");
243+
channel.queueDeclare("durable_q", true, false, false, null);
244+
route("/amq/queue/durable_q", "/amq/queue/durable_q", "", true);
245+
channel.queueDelete("durable_q");
246+
channel.queueDeclare("autodel_q", false, false, true, null);
247+
route("/amq/queue/autodel_q", "/amq/queue/autodel_q", "", true);
248+
channel.queueDelete("autodel_q");
249+
connection.close();
250+
233251
route("/exchange/amq.direct/b", "/exchange/amq.direct", "a", false);
234252
route(QUEUE, "/exchange/amq.fanout", "", false);
235253
route(QUEUE, "/exchange/amq.headers", "", false);
@@ -243,7 +261,7 @@ public void testRoutingInvalidRoutes() throws Exception {
243261
channel.queueDeclare("transient", false, false, false, null);
244262
connection.close();
245263

246-
for (String dest : Arrays.asList("/exchange/missing", "/queue/transient", "/fruit/orange")) {
264+
for (String dest : Arrays.asList("/exchange/missing", "/fruit/orange")) {
247265
routeInvalidSource(dest);
248266
routeInvalidTarget(dest);
249267
}

0 commit comments

Comments
 (0)