Skip to content

Commit 1993e53

Browse files
Introduce Channel#queueDeleteNowait
1 parent 0909039 commit 1993e53

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

src/com/rabbitmq/client/Channel.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,18 @@ void queueDeclareNowait(String queue, boolean durable, boolean exclusive, boolea
528528
*/
529529
Queue.DeleteOk queueDelete(String queue, boolean ifUnused, boolean ifEmpty) throws IOException;
530530

531+
/**
532+
* Like {@link Channel#queueDelete(String, boolean, boolean)} but sets nowait parameter
533+
* to true and returns nothing (as there will be no response from the server).
534+
* @see com.rabbitmq.client.AMQP.Queue.Delete
535+
* @see com.rabbitmq.client.AMQP.Queue.DeleteOk
536+
* @param queue the name of the queue
537+
* @param ifUnused true if the queue should be deleted only if not in use
538+
* @param ifEmpty true if the queue should be deleted only if empty
539+
* @throws java.io.IOException if an error is encountered
540+
*/
541+
void queueDeleteNowait(String queue, boolean ifUnused, boolean ifEmpty) throws IOException;
542+
531543
/**
532544
* Bind a queue to an exchange, with no extra arguments.
533545
* @see com.rabbitmq.client.AMQP.Queue.Bind

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,16 @@ public Queue.DeleteOk queueDelete(String queue, boolean ifUnused, boolean ifEmpt
870870
.getMethod();
871871
}
872872

873+
@Override
874+
public void queueDeleteNowait(String queue, boolean ifUnused, boolean ifEmpty) throws IOException {
875+
transmit(new AMQCommand(new Queue.Delete.Builder()
876+
.queue(queue)
877+
.ifUnused(ifUnused)
878+
.ifEmpty(ifEmpty)
879+
.nowait(true)
880+
.build()));
881+
}
882+
873883
/** Public API - {@inheritDoc} */
874884
public Queue.DeleteOk queueDelete(String queue)
875885
throws IOException

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ public AMQP.Queue.DeleteOk queueDelete(String queue, boolean ifUnused, boolean i
278278
return delegate.queueDelete(queue, ifUnused, ifEmpty);
279279
}
280280

281+
@Override
282+
public void queueDeleteNowait(String queue, boolean ifUnused, boolean ifEmpty) throws IOException {
283+
deleteRecordedQueue(queue);
284+
delegate.queueDeleteNowait(queue, ifUnused, ifEmpty);
285+
}
286+
281287
public AMQP.Queue.BindOk queueBind(String queue, String exchange, String routingKey) throws IOException {
282288
return queueBind(queue, exchange, routingKey, null);
283289
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,10 @@ public void testExchangeBindWithNowait() throws IOException {
3737
}
3838
}
3939

40+
public void testQueueDeleteWithNowait() throws IOException {
41+
String q = generateQueueName();
42+
channel.queueDeclareNowait(q, false, true, true, null);
43+
channel.queueDeleteNowait(q, false, false);
44+
}
45+
4046
}

0 commit comments

Comments
 (0)