{
//The vhostManager MBean wasnt found, cant procede
return false;
}
ManagedBroker vhostManager = (ManagedBroker) MBeanServerInvocationHandler.newProxyInstance(
mbsc, (ObjectName) vhostManagers.toArray()[0], ManagedBroker.class, false);
ObjectName customExchangeObjectName = new ObjectName(
"org.apache.qpid:" +
"type=VirtualHost.Exchange," +
"VirtualHost=" + virHost + "," +
"name=" + exchName + "," +
"ExchangeType=direct,*");
Set<ObjectName> exchanges = mbsc.queryNames(customExchangeObjectName, null);
if(exchanges.size() == 0)
{
//The exchange doesnt exist, cant procede.
return false;
}
//create the MBean proxy
ManagedExchange managedExchange = (ManagedExchange) MBeanServerInvocationHandler.newProxyInstance(
mbsc, (ObjectName) exchanges.toArray()[0], ManagedExchange.class, false);
try
{
//create the new durable queue and bind it.
vhostManager.createNewQueue(queueName, null, true);
managedExchange.createNewBinding(queueName,queueName);
}
catch (Exception e)
{
System.out.println("Could not add queue due to exception :" + e.getMessage());