public void methodReceived(AMQStateManager stateManager, AMQMethodEvent<ExchangeBoundBody> evt) throws AMQException
{
AMQProtocolSession session = stateManager.getProtocolSession();
VirtualHost virtualHost = session.getVirtualHost();
QueueRegistry queueRegistry = virtualHost.getQueueRegistry();
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
byte major = (byte)8;
byte minor = (byte)0;
ExchangeBoundBody body = evt.getMethod();
AMQShortString exchangeName = body.exchange;
AMQShortString queueName = body.queue;
AMQShortString routingKey = body.routingKey;
if (exchangeName == null)
{
throw new AMQException("Exchange exchange must not be null");
}
Exchange exchange = virtualHost.getExchangeRegistry().getExchange(exchangeName);
AMQFrame response;
if (exchange == null)
{
// AMQP version change: Be aware of possible changes to parameter order as versions change.
response = ExchangeBoundOkBody.createAMQFrame(evt.getChannelId(),
major, minor, // AMQP version (major, minor)
EXCHANGE_NOT_FOUND, // replyCode
new AMQShortString("Exchange " + exchangeName + " not found")); // replyText
}
else if (routingKey == null)
{
if (queueName == null)
{
if (exchange.hasBindings())
{
// AMQP version change: Be aware of possible changes to parameter order as versions change.
response = ExchangeBoundOkBody.createAMQFrame(evt.getChannelId(),
major, minor, // AMQP version (major, minor)
OK, // replyCode
null); // replyText
}
else
{
// AMQP version change: Be aware of possible changes to parameter order as versions change.
response = ExchangeBoundOkBody.createAMQFrame(evt.getChannelId(),
major, minor, // AMQP version (major, minor)
NO_BINDINGS, // replyCode
null); // replyText
}
}
else
{
AMQQueue queue = queueRegistry.getQueue(queueName);
if (queue == null)
{
// AMQP version change: Be aware of possible changes to parameter order as versions change.
response = ExchangeBoundOkBody.createAMQFrame(evt.getChannelId(),
major, minor, // AMQP version (major, minor)
QUEUE_NOT_FOUND, // replyCode
new AMQShortString("Queue " + queueName + " not found")); // replyText
}
else
{
if (exchange.isBound(queue))
{
// AMQP version change: Be aware of possible changes to parameter order as versions change.
response = ExchangeBoundOkBody.createAMQFrame(evt.getChannelId(),
major, minor, // AMQP version (major, minor)
OK, // replyCode
null); // replyText
}
else
{
// AMQP version change: Be aware of possible changes to parameter order as versions change.
response = ExchangeBoundOkBody.createAMQFrame(evt.getChannelId(),
major, minor, // AMQP version (major, minor)
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)
{
// AMQP version change: Be aware of possible changes to parameter order as versions change.
response = ExchangeBoundOkBody.createAMQFrame(evt.getChannelId(),
major, minor, // AMQP version (major, minor)