{
String queueName = method.getQueue();
QueueRegistry queueRegistry = getQueueRegistry(session);
final AMQQueue queue = queueRegistry.getQueue(queueName);
if(queue == null)
{
exception(session,method,ExecutionErrorCode.NOT_FOUND, "Queue: " + queueName + " not found");
}
else if(queue.getAuthorizationHolder() != null && queue.getAuthorizationHolder() != session)
{
exception(session,method,ExecutionErrorCode.RESOURCE_LOCKED, "Exclusive Queue: " + queueName + " owned exclusively by another session");
}
else if(queue.isExclusive() && queue.getExclusiveOwningSession() != null && queue.getExclusiveOwningSession() != session)
{
exception(session,method,ExecutionErrorCode.RESOURCE_LOCKED, "Exclusive Queue: " + queueName + " owned exclusively by another session");
}
else
{
if(queue.isExclusive())
{
ServerSession s = (ServerSession) session;
queue.setExclusiveOwningSession(s);
if(queue.getAuthorizationHolder() == null)
{
queue.setAuthorizationHolder(s);
queue.setExclusiveOwningSession(s);
((ServerSession) session).addSessionCloseTask(new ServerSession.Task()
{
public void doTask(ServerSession session)
{
if(queue.getAuthorizationHolder() == session)
{
queue.setAuthorizationHolder(null);
queue.setExclusiveOwningSession(null);
}
}
});
}
}
FlowCreditManager_0_10 creditManager = new WindowCreditManager(0L,0L);
FilterManager filterManager = null;
try
{
filterManager = FilterManagerFactory.createManager(method.getArguments());
}
catch (AMQException amqe)
{
exception(session, method, ExecutionErrorCode.ILLEGAL_ARGUMENT, "Exception Creating FilterManager");
return;
}
Subscription_0_10 sub = SubscriptionFactoryImpl.INSTANCE.createSubscription((ServerSession)session,
destination,
method.getAcceptMode(),
method.getAcquireMode(),
MessageFlowMode.WINDOW,
creditManager,
filterManager,
method.getArguments());
((ServerSession)session).register(destination, sub);
try
{
queue.registerSubscription(sub, method.getExclusive());
}
catch (AMQQueue.ExistingExclusiveSubscription existing)
{
exception(session, method, ExecutionErrorCode.RESOURCE_LOCKED, "Queue has an exclusive consumer");
}