//First deactivate
if (isQueue)
{
Binding binding = postOffice.getBindingForQueueName(name);
if (binding != null)
{
binding.getQueue().deactivate();
}
}
else
{
JMSCondition topicCond = new JMSCondition(false, name);
Collection bindings = postOffice.getBindingsForCondition(topicCond);
Iterator iter = bindings.iterator();
while (iter.hasNext())
{
Binding binding = (Binding)iter.next();
binding.getQueue().deactivate();
}
}
//Delete any message data
mbeanServer.invoke(on, "removeAllMessages", null, null);
//undeploy the mbean
if (!undeployDestination(isQueue, name))
{
return false;
}
//Unbind from the post office
if (isQueue)
{
Binding binding = postOffice.getBindingForQueueName(name);
if (binding != null)
{
try
{
Queue queue = binding.getQueue();
if (!queue.isClustered())
{
postOffice.unbindQueue(queue.getName());
}
else
{
((ClusteredPostOffice)postOffice).unbindClusteredQueue(queue.getName());
}
}
catch (Throwable t)
{
throw new Exception("Failed to unbind queue", t);
}
}
}
else
{
JMSCondition topicCond = new JMSCondition(false, name);
Collection bindings = postOffice.getBindingsForCondition(topicCond);
Iterator iter = bindings.iterator();
while (iter.hasNext())
{
Binding binding = (Binding)iter.next();
try
{
postOffice.unbindQueue(binding.getQueue().getName());
}
catch (Throwable t)
{
throw new Exception("Failed to unbind queue", t);
}