public void methodReceived(AMQStateManager stateManager, ExchangeBoundBody body, int channelId) throws AMQException
{
AMQProtocolSession session = stateManager.getProtocolSession();
VirtualHost virtualHost = session.getVirtualHost();
QueueRegistry queueRegistry = virtualHost.getQueueRegistry();
MethodRegistry methodRegistry = session.getMethodRegistry();
final AMQChannel channel = session.getChannel(channelId);
if (channel == null)
{
throw body.getChannelNotFoundException(channelId);
}
channel.sync();
AMQShortString exchangeName = body.getExchange();
AMQShortString queueName = body.getQueue();
AMQShortString routingKey = body.getRoutingKey();
if (exchangeName == null)
{
throw new AMQException("Exchange exchange must not be null");
}
Exchange exchange = virtualHost.getExchange(exchangeName.toString());
ExchangeBoundOkBody response;
if (exchange == null)
{
response = methodRegistry.createExchangeBoundOkBody(EXCHANGE_NOT_FOUND,
new AMQShortString("Exchange " + exchangeName + " not found"));
}
else if (routingKey == null)
{
if (queueName == null)
{
if (exchange.hasBindings())
{
response = methodRegistry.createExchangeBoundOkBody(OK, null);
}
else
{
response = methodRegistry.createExchangeBoundOkBody(NO_BINDINGS, // replyCode
null); // replyText
}
}
else
{
AMQQueue queue = queueRegistry.getQueue(queueName);
if (queue == null)
{
response = methodRegistry.createExchangeBoundOkBody(QUEUE_NOT_FOUND, // replyCode
new AMQShortString("Queue " + queueName + " not found")); // replyText
}
else
{
if (exchange.isBound(queue))
{
response = methodRegistry.createExchangeBoundOkBody(OK, // replyCode
null); // replyText
}
else
{
response = methodRegistry.createExchangeBoundOkBody(QUEUE_NOT_BOUND, // replyCode
new AMQShortString("Queue " + queueName + " not bound to exchange " + exchangeName)); // replyText
}
}
}
}
else if (queueName != null)
{
AMQQueue queue = queueRegistry.getQueue(queueName);
if (queue == null)
{
response = methodRegistry.createExchangeBoundOkBody(QUEUE_NOT_FOUND, // replyCode
new AMQShortString("Queue " + queueName + " not found")); // replyText