Skip to content

Instantly share code, notes, and snippets.

@jshiell
Created August 6, 2012 07:31
Show Gist options
  • Save jshiell/3271941 to your computer and use it in GitHub Desktop.
Save jshiell/3271941 to your computer and use it in GitHub Desktop.
Unbind and delete a queue from a RabbitMQ node.
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import java.io.IOException;
public class Unbinder {
public static void main(final String[] args) {
final ConnectionFactory factory = new ConnectionFactory();
factory.setHost("aServer");
factory.setPort(5672);
factory.setUsername("aUser");
factory.setPassword("aPassword");
factory.setVirtualHost("aVHost");
try {
final Connection connection = factory.newConnection();
final Channel channel = connection.createChannel();
try {
channel.exchangeDeclarePassive("anExchange");
channel.queueUnbind("aQueue", "anExchange", "aRoutingKey");
channel.queueDelete("aQueue");
} finally {
channel.close();
connection.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment