}
public void methodReceived(AMQStateManager stateManager, QueueBindBody body, int channelId) throws AMQException
{
AMQProtocolSession protocolConnection = stateManager.getProtocolSession();
VirtualHost virtualHost = protocolConnection.getVirtualHost();
AMQChannel channel = protocolConnection.getChannel(channelId);
if (channel == null)
{
throw body.getChannelNotFoundException(channelId);
}
final AMQQueue queue;
final AMQShortString routingKey;
final AMQShortString queueName = body.getQueue();
if (queueName == null)
{
queue = channel.getDefaultQueue();
if (queue == null)
{
throw body.getChannelException(AMQConstant.NOT_FOUND, "No default queue defined on channel and queue was null");
}
if (body.getRoutingKey() == null)
{
routingKey = AMQShortString.valueOf(queue.getName());
}
else
{
routingKey = body.getRoutingKey().intern();
}
}
else
{
queue = virtualHost.getQueue(queueName.toString());
routingKey = body.getRoutingKey() == null ? AMQShortString.EMPTY_STRING : body.getRoutingKey().intern();
}
if (queue == null)
{
throw body.getChannelException(AMQConstant.NOT_FOUND, "Queue " + queueName + " does not exist.");
}
final String exchangeName = body.getExchange() == null ? null : body.getExchange().toString();
final Exchange exch = virtualHost.getExchange(exchangeName);
if (exch == null)
{
throw body.getChannelException(AMQConstant.NOT_FOUND, "Exchange " + exchangeName + " does not exist.");
}