Skip to content

Commit 07d9bd1

Browse files
committed
merge bug19250 into default
2 parents d0d055f + 7b3d8a5 commit 07d9bd1

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed

src/com/rabbitmq/client/Channel.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,19 @@ Queue.DeclareOk queueDeclare(int ticket, String queue, boolean passive, boolean
305305
*/
306306
Queue.BindOk queueBind(int ticket, String queue, String exchange, String routingKey) throws IOException;
307307

308+
/**
309+
* Uninds a queue from an exchange, with no extra arguments.
310+
* @see com.rabbitmq.client.AMQP.Queue.Unbind
311+
* @see com.rabbitmq.client.AMQP.Queue.UnbindOk
312+
* @param ticket an access ticket for the appropriate realm
313+
* @param queue the name of the queue
314+
* @param exchange the name of the exchange
315+
* @param routingKey the routine key to use for the binding
316+
* @return an unbinding-confirm method if the binding was successfully deleted
317+
* @throws java.io.IOException if an error is encountered
318+
*/
319+
Queue.UnbindOk queueUnbind(int ticket, String queue, String exchange, String routingKey) throws IOException;
320+
308321
/**
309322
* Bind a queue to an exchange.
310323
* @see com.rabbitmq.client.AMQP.Queue.Bind
@@ -319,6 +332,20 @@ Queue.DeclareOk queueDeclare(int ticket, String queue, boolean passive, boolean
319332
*/
320333
Queue.BindOk queueBind(int ticket, String queue, String exchange, String routingKey, Map<String, Object> arguments) throws IOException;
321334

335+
/**
336+
* Unbind a queue from an exchange.
337+
* @see com.rabbitmq.client.AMQP.Queue.Unbind
338+
* @see com.rabbitmq.client.AMQP.Queue.UnbindOk
339+
* @param ticket an access ticket for the appropriate realm
340+
* @param queue the name of the queue
341+
* @param exchange the name of the exchange
342+
* @param routingKey the routine key to use for the binding
343+
* @param arguments other properties (binding parameters)
344+
* @return an unbinding-confirm method if the binding was successfully deleted
345+
* @throws java.io.IOException if an error is encountered
346+
*/
347+
Queue.UnbindOk queueUnbind(int ticket, String queue, String exchange, String routingKey, Map<String, Object> arguments) throws IOException;
348+
322349
/**
323350
* Retrieve a message from a queue using {@link com.rabbitmq.client.AMQP.Basic.Get}
324351
* @see com.rabbitmq.client.AMQP.Basic.Get

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,20 @@ public Queue.BindOk queueBind(int ticket, String queue, String exchange,
535535
false, arguments)).getMethod();
536536
}
537537

538+
/**
539+
* Public API - Unbind a queue from an exchange.
540+
* @see com.rabbitmq.client.AMQP.Queue.Unbind
541+
* @see com.rabbitmq.client.AMQP.Queue.UnbindOk
542+
*/
543+
public Queue.UnbindOk queueUnbind(int ticket, String queue, String exchange,
544+
String routingKey, Map<String, Object> arguments)
545+
throws IOException
546+
{
547+
return (Queue.UnbindOk)
548+
exnWrappingRpc(new Queue.Unbind(ticket, queue, exchange, routingKey,
549+
arguments)).getMethod();
550+
}
551+
538552
/**
539553
* Public API - Bind a queue to an exchange, with no extra arguments.
540554
* @see com.rabbitmq.client.AMQP.Queue.Bind
@@ -546,6 +560,17 @@ public Queue.BindOk queueBind(int ticket, String queue, String exchange, String
546560
return queueBind(ticket, queue, exchange, routingKey, null);
547561
}
548562

563+
/**
564+
* Public API - Unbind a queue from an exchange, with no extra arguments.
565+
* @see com.rabbitmq.client.AMQP.Queue.Unbind
566+
* @see com.rabbitmq.client.AMQP.Queue.UnbindOk
567+
*/
568+
public Queue.UnbindOk queueUnbind(int ticket, String queue, String exchange, String routingKey)
569+
throws IOException
570+
{
571+
return queueUnbind(ticket, queue, exchange, routingKey, null);
572+
}
573+
549574
/**
550575
* Public API - Retrieve a message from a queue using {@link com.rabbitmq.client.AMQP.Basic.Get}
551576
* @see com.rabbitmq.client.AMQP.Basic.Get

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525

2626
package com.rabbitmq.client.test.functional;
2727

28-
import java.io.IOException;
29-
28+
import com.rabbitmq.client.AMQP;
3029
import com.rabbitmq.client.GetResponse;
3130

31+
import java.io.IOException;
32+
3233
public class Routing extends BrokerTestCase
3334
{
3435

@@ -119,4 +120,23 @@ public void testDoubleBinding()
119120
checkGet(Q1, true);
120121
checkGet(Q1, false);
121122
}
123+
124+
public void testUnbind() throws Exception {
125+
AMQP.Queue.DeclareOk ok = channel.queueDeclare(ticket);
126+
String queue = ok.getQueue();
127+
128+
String routingKey = "quay";
129+
String x = "amq.direct";
130+
131+
channel.queueBind(ticket, queue, x, routingKey);
132+
channel.basicPublish(ticket, x, routingKey, null, "foobar".getBytes());
133+
checkGet(queue, true);
134+
135+
channel.queueUnbind(ticket, queue, x, routingKey);
136+
137+
channel.basicPublish(ticket, x, routingKey, null, "foobar".getBytes());
138+
checkGet(queue, false);
139+
140+
channel.queueDelete(ticket, queue);
141+
}
122142
}

0 commit comments

Comments
 (0)