Example usage for com.rabbitmq.client Channel queueDelete

List of usage examples for com.rabbitmq.client Channel queueDelete

Introduction

In this page you can find the example usage for com.rabbitmq.client Channel queueDelete.

Prototype

Queue.DeleteOk queueDelete(String queue, boolean ifUnused, boolean ifEmpty) throws IOException;

Source Link

Document

Delete a queue

Usage

From source file:org.ballerinalang.messaging.rabbitmq.util.ChannelUtils.java

License:Open Source License

/**
 * Deletes a queue./*from w  ww.j  a v  a2  s  .  c  o  m*/
 *
 * @param channel   RabbitMQ Channel object.
 * @param queueName Name of the queue.
 * @param ifUnused  True if the queue should be deleted only if not in use.
 * @param ifEmpty   True if the queue should be deleted only if empty.
 */
public static void queueDelete(Channel channel, String queueName, BValue ifUnused, BValue ifEmpty) {
    boolean isValidValues = ifUnused instanceof BBoolean && ifEmpty instanceof BBoolean;
    try {
        if (isValidValues) {
            channel.queueDelete(queueName, ((BBoolean) ifUnused).booleanValue(),
                    ((BBoolean) ifEmpty).booleanValue());
        } else {
            channel.queueDelete(queueName);
        }
    } catch (Exception exception) {
        String errorMessage = "An error occurred while deleting the queue ";
        throw new RabbitMQConnectorException(errorMessage + exception.getMessage(), exception);
    }
}

From source file:org.springframework.amqp.rabbit.core.RabbitAdmin.java

License:Apache License

@Override
@ManagedOperation//from w  w w . j  a v  a2  s  . co m
public void deleteQueue(final String queueName, final boolean unused, final boolean empty) {
    this.rabbitTemplate.execute(new ChannelCallback<Object>() {
        @Override
        public Object doInRabbit(Channel channel) throws Exception {
            channel.queueDelete(queueName, unused, empty);
            return null;
        }
    });
}