public void methodReceived(AMQProtocolSession session, ConnectionTuneBody frame, int channelId)
{
_logger.debug("ConnectionTune frame received");
final MethodRegistry methodRegistry = session.getMethodRegistry();
ConnectionTuneParameters params = session.getConnectionTuneParameters();
int maxChannelNumber = frame.getChannelMax();
//0 implies no limit, except that forced by protocol limitations (0xFFFF)
params.setChannelMax(maxChannelNumber == 0 ? AMQProtocolSession.MAX_CHANNEL_MAX : maxChannelNumber);
params.setFrameMax(frame.getFrameMax());
//if the heart beat delay hasn't been configured, we use the broker-supplied value
if (params.getHeartbeat() == null)
{
params.setHeartbeat(frame.getHeartbeat());
}
session.tuneConnection(params);
session.getStateManager().changeState(AMQState.CONNECTION_NOT_OPENED);
ConnectionTuneOkBody tuneOkBody = methodRegistry.createConnectionTuneOkBody(params.getChannelMax(),
params.getFrameMax(),
params.getHeartbeat());
session.setMaxFrameSize(params.getFrameMax());
// Be aware of possible changes to parameter order as versions change.
session.writeFrame(tuneOkBody.generateFrame(channelId));
String host = session.getAMQConnection().getVirtualHost();
AMQShortString virtualHost = new AMQShortString("/" + host);