/// <summary>
/// Handle incoming commands
/// </summary>
/// <param name="commandTransport">An ITransport</param>
/// <param name="command">A Command</param>
protected void OnCommand(ITransport commandTransport, Command command)
{
if (command is MessageDispatch)
{
DispatchMessage((MessageDispatch)command);
}
else if (command is KeepAliveInfo)
{
OnKeepAliveCommand(commandTransport, (KeepAliveInfo)command);
}
else if (command is WireFormatInfo)
{
this.brokerWireFormatInfo = (WireFormatInfo)command;
}
else if (command is BrokerInfo)
{
this.brokerInfo = (BrokerInfo)command;
}
else if (command is ShutdownInfo)
{
if (!closing && !closed)
{
OnException(commandTransport, new NMSException("Broker closed this connection."));
}
}
else if (command is ProducerAck)
{
ProducerAck ack = (ProducerAck)command;
if (ack != null && ack.ProducerId != null)
{
MessageProducer producer = (MessageProducer)producers[ack.ProducerId];
if (producer != null)
{
producer.OnProducerAck(ack);
}
}
}
else if (command is ConnectionError)
{
if (!closing && !closed)
{
ConnectionError connectionError = (ConnectionError)command;
BrokerError brokerError = connectionError.Exception;
string message = "Broker connection error.";
string cause = "";
if (null != brokerError)
{
message = brokerError.Message;
if (null != brokerError.Cause)
{
cause = brokerError.Cause.Message;
}
}
OnException(commandTransport, new NMSConnectionException(message, cause));
}
}
else
{
Tracer.Error("Unknown command: " + command);
}
}