public void CloseSession(AmqChannel channel) { // FIXME: Don't we need FailoverSupport here (as we have SyncWrite). _protocolSession.CloseSession(channel); AMQFrame frame = ChannelCloseBody.CreateAMQFrame( channel.ChannelId, 200, "JMS client closing channel", 0, 0); _log.Debug("Blocking for channel close frame for channel " + channel.ChannelId); _protocolWriter.SyncWrite(frame, typeof(ChannelCloseOkBody)); _log.Debug("Received channel close frame"); // When control resumes at this point, a reply will have been received that // indicates the broker has closed the channel successfully }
public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) { _logger.Debug("ChannelClose method received"); ChannelCloseBody method = (ChannelCloseBody)evt.Method; int errorCode = method.ReplyCode; string reason = method.ReplyText; if (_logger.IsDebugEnabled) { _logger.Debug("Channel close reply code: " + errorCode + ", reason: " + reason); } AMQFrame frame = ChannelCloseOkBody.CreateAMQFrame(evt.ChannelId); evt.ProtocolSession.WriteFrame(frame); if (errorCode != AMQConstant.REPLY_SUCCESS.Code) { _logger.Debug("Channel close received with errorCode " + errorCode + ", throwing exception"); if (errorCode == AMQConstant.NO_CONSUMERS.Code) { throw new AMQNoConsumersException(reason); } if (errorCode == AMQConstant.NO_ROUTE.Code) { throw new AMQNoRouteException(reason); } if (errorCode == AMQConstant.INVALID_ARGUMENT.Code) { throw new AMQInvalidArgumentException(reason); } if (errorCode == AMQConstant.INVALID_ROUTING_KEY.Code) { throw new AMQInvalidRoutingKeyException(reason); } // any other throw new AMQChannelClosedException(errorCode, "Error: " + reason); } evt.ProtocolSession.ChannelClosed(evt.ChannelId, errorCode, reason); }