MethodRegistry methodRegistry = session.getMethodRegistry();
// We don't implement access control class, but to keep clients happy that expect it
// always use the "0" ticket.
AccessRequestOkBody response;
if(methodRegistry instanceof MethodRegistry_0_9)
{
response = ((MethodRegistry_0_9)methodRegistry).createAccessRequestOkBody(0);
}
else if(methodRegistry instanceof MethodRegistry_8_0)
{
response = ((MethodRegistry_8_0)methodRegistry).createAccessRequestOkBody(0);
}
else
{
throw new AMQException(AMQConstant.COMMAND_INVALID, "AccessRequest not present in AMQP versions other than 0-8, 0-9");
}
channel.sync();
session.writeFrame(response.generateFrame(channelId));
}