AMQProtocolSession session = stateManager.getProtocolSession();
BasicConsumeBody body = evt.getMethod();
final int channelId = evt.getChannelId();
AMQChannel channel = session.getChannel(channelId);
VirtualHost vHost = session.getVirtualHost();
if (channel == null)
{
throw body.getChannelNotFoundException(evt.getChannelId());
}
else
{
if (_log.isDebugEnabled())
{
_log.debug("BasicConsume: from '" + body.queue +
"' for:" + body.consumerTag +
" nowait:" + body.nowait +
" args:" + body.arguments);
}
AMQQueue queue = body.queue == null ? channel.getDefaultQueue() : vHost.getQueueRegistry().getQueue(body.queue);
if (queue == null)
{
if (_log.isTraceEnabled())
{
_log.trace("No queue for '" + body.queue + "'");
}
if (body.queue != null)
{
String msg = "No such queue, '" + body.queue + "'";
throw body.getChannelException(AMQConstant.NOT_FOUND, msg);
}
else
{
String msg = "No queue name provided, no default queue defined.";
throw body.getConnectionException(AMQConstant.NOT_ALLOWED, msg);
}
}
else
{
if (body.consumerTag != null)
{
body.consumerTag = body.consumerTag.intern();
}
try
{
AMQShortString consumerTag = channel.subscribeToQueue(body.consumerTag, queue, session, !body.noAck,
body.arguments, body.noLocal, body.exclusive);
if (!body.nowait)
{
// 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.