// get a reference to the destination and use it while it is still being loaded. Also,
// binding might already exist.
PostOffice po = serverPeer.getPostOfficeInstance();
Binding binding = po.getBindingForQueueName(destination.getName());
Queue queue;
if (binding != null)
{
queue = binding.queue;
if (queue.isActive())
{
throw new IllegalStateException("Cannot deploy queue " + destination.getName() + " it is already deployed");
}
//Sanity check - currently it is not possible to change the clustered attribute of a destination
//See http://jira.jboss.org/jira/browse/JBMESSAGING-1235
boolean actuallyClustered = po.isClustered() && destination.isClustered();
if (actuallyClustered != queue.isClustered())
{
throw new IllegalArgumentException("Queue " + destination.getName() + " is already deployed as clustered = " +
queue.isClustered() + " so cannot redeploy as clustered=" + destination.isClustered() +
" . You must delete the destination first before redeploying");
}
queue.setPagingParams(destination.getFullSize(),
destination.getPageSize(),
destination.getDownCacheSize());
queue.load();
// Must be done after load
queue.setMaxSize(destination.getMaxSize());
queue.activate();
}
else
{
// Create a new queue
JMSCondition queueCond = new JMSCondition(true, destination.getName());
queue = new MessagingQueue(nodeId, destination.getName(),
serverPeer.getChannelIDManager().getID(),
serverPeer.getMessageStore(), serverPeer.getPersistenceManagerInstance(),
true,
destination.getMaxSize(), null,
destination.getFullSize(), destination.getPageSize(),
destination.getDownCacheSize(), destination.isClustered(),
serverPeer.getRecoverDeliveriesTimeout());
po.addBinding(new Binding(queueCond, queue, false), false);
queue.activate();
}
((ManagedQueue)destination).setQueue(queue);