Skip to content

Commit 8dbfc35

Browse files
Introduce Channel#queueBindNowait, commit missing test file
1 parent 9ad7b18 commit 8dbfc35

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

src/com/rabbitmq/client/Channel.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,18 @@ Queue.DeclareOk queueDeclare(String queue, boolean durable, boolean exclusive, b
507507
*/
508508
Queue.BindOk queueBind(String queue, String exchange, String routingKey, Map<String, Object> arguments) throws IOException;
509509

510+
/**
511+
* Same as {@link Channel#queueDeclare(String, boolean, boolean, boolean, java.util.Map)} but sets nowait
512+
* parameter to true and returns void (as there will be no response
513+
* from the server).
514+
* @param queue the name of the queue
515+
* @param exchange the name of the exchange
516+
* @param routingKey the routine key to use for the binding
517+
* @param arguments other properties (binding parameters)
518+
* @throws java.io.IOException if an error is encountered
519+
*/
520+
void queueBindNowait(String queue, String exchange, String routingKey, Map<String, Object> arguments) throws IOException;
521+
510522
/**
511523
* Unbinds a queue from an exchange, with no extra arguments.
512524
* @see com.rabbitmq.client.AMQP.Queue.Unbind

src/com/rabbitmq/client/impl/ChannelN.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,19 @@ public Queue.BindOk queueBind(String queue, String exchange, String routingKey)
851851
return queueBind(queue, exchange, routingKey, null);
852852
}
853853

854+
/** Public API - {@inheritDoc} */
855+
public void queueBindNowait(String queue,
856+
String exchange,
857+
String routingKey,
858+
Map<String, Object> arguments) throws IOException {
859+
transmit(new AMQCommand(new Queue.Bind.Builder()
860+
.queue(queue)
861+
.exchange(exchange)
862+
.routingKey(routingKey)
863+
.arguments(arguments)
864+
.build()));
865+
}
866+
854867
/** Public API - {@inheritDoc} */
855868
public Queue.UnbindOk queueUnbind(String queue, String exchange, String routingKey,
856869
Map<String, Object> arguments)

src/com/rabbitmq/client/impl/recovery/AutorecoveringChannel.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ public AMQP.Queue.BindOk queueBind(String queue, String exchange, String routing
263263
return ok;
264264
}
265265

266+
public void queueBindNowait(String queue, String exchange, String routingKey, Map<String, Object> arguments) throws IOException {
267+
delegate.queueBindNowait(queue, exchange, routingKey, arguments);
268+
recordQueueBinding(queue, exchange, routingKey, arguments);
269+
}
270+
266271
public AMQP.Queue.UnbindOk queueUnbind(String queue, String exchange, String routingKey) throws IOException {
267272
return queueUnbind(queue, exchange, routingKey, null);
268273
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.rabbitmq.client.test.functional;
2+
3+
import com.rabbitmq.client.test.BrokerTestCase;
4+
5+
import java.io.IOException;
6+
7+
public class Nowait extends BrokerTestCase {
8+
public void testQueueDeclareWithNowait() throws IOException {
9+
String q = generateQueueName();
10+
channel.queueDeclareNowait(q, false, true, true, null);
11+
channel.queueDeclarePassive(q);
12+
}
13+
14+
public void testQueueBindWithNowait() throws IOException {
15+
String q = generateQueueName();
16+
channel.queueDeclareNowait(q, false, true, true, null);
17+
channel.queueBindNowait(q, "amq.fanout", "", null);
18+
}
19+
20+
public void testExchangeDeclareWithNowait() throws IOException {
21+
String x = generateExchangeName();
22+
try {
23+
channel.exchangeDeclareNowait(x, "fanout", false, false, false, null);
24+
channel.exchangeDeclarePassive(x);
25+
} finally {
26+
channel.exchangeDelete(x);
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)