示例#1
0
 public BrokerException(BrokerError brokerError)
     : this(brokerError, null)
 {
 }
示例#2
0
 public BrokerException(BrokerError brokerError, Exception innerException = null)
     : base(brokerError.ExceptionClass + " : " + brokerError.Message + "\n" + StackTraceDump(brokerError.StackTraceElements),
            innerException)
     => BrokerError = brokerError;
示例#3
0
 public BrokerException(BrokerError brokerError) : base(
         brokerError.ExceptionClass + " : " + brokerError.Message + "\n" + StackTraceDump(brokerError.StackTraceElements))
 {
     this.brokerError = brokerError;
 }
示例#4
0
        /// <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.IsMessageDispatch)
            {
                WaitForTransportInterruptionProcessingToComplete();
                DispatchMessage((MessageDispatch)command);
            }
            else if (command.IsKeepAliveInfo)
            {
                OnKeepAliveCommand(commandTransport, (KeepAliveInfo)command);
            }
            else if (command.IsWireFormatInfo)
            {
                this.brokerWireFormatInfo = (WireFormatInfo)command;
            }
            else if (command.IsBrokerInfo)
            {
                this.brokerInfo = (BrokerInfo)command;
                this.brokerInfoReceived.countDown();
            }
            else if (command.IsShutdownInfo)
            {
                if (!closing.Value && !closed.Value)
                {
                    OnException(new NMSException("Broker closed this connection."));
                }
            }
            else if (command.IsProducerAck)
            {
                ProducerAck ack = (ProducerAck)command as ProducerAck;
                if (ack.ProducerId != null)
                {
                    MessageProducer producer = producers[ack.ProducerId] as MessageProducer;
                    if (producer != null)
                    {
                        if (Tracer.IsDebugEnabled)
                        {
                            Tracer.Debug("Connection: Received a new ProducerAck -> " + ack);
                        }

                        producer.OnProducerAck(ack);
                    }
                }
            }
            else if (command.IsConnectionError)
            {
                if (!closing.Value && !closed.Value)
                {
                    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(new NMSConnectionException(message, cause));
                }
            }
            else
            {
                Tracer.Error("Unknown command: " + command);
            }
        }
示例#5
0
        protected virtual Object CreateCommand(StompFrame frame)
        {
            string command = frame.Command;

            if (command == "RECEIPT" || command == "CONNECTED")
            {
                string text = frame.RemoveProperty("receipt-id");
                if (text != null)
                {
                    Response answer = new Response();
                    if (text.StartsWith("ignore:"))
                    {
                        text = text.Substring("ignore:".Length);
                    }

                    Tracer.Debug("StompWireFormat - Received RESPONSE command: CorrelationId = " + text);

                    answer.CorrelationId = Int32.Parse(text);
                    return(answer);
                }
                else if (command == "CONNECTED")
                {
                    text = frame.RemoveProperty("response-id");

                    Tracer.Debug("StompWireFormat - Received CONNECTED command: ResponseId = " + text);

                    if (text != null)
                    {
                        Response answer = new Response();
                        answer.CorrelationId = Int32.Parse(text);
                        return(answer);
                    }
                }
            }
            else if (command == "ERROR")
            {
                string text = frame.RemoveProperty("receipt-id");

                if (text != null && text.StartsWith("ignore:"))
                {
                    Tracer.Debug("StompWireFormat - Received ERROR Response command: correlationId = " + text);
                    Response answer = new Response();
                    answer.CorrelationId = Int32.Parse(text.Substring("ignore:".Length));
                    return(answer);
                }
                else
                {
                    ExceptionResponse answer = new ExceptionResponse();
                    if (text != null)
                    {
                        answer.CorrelationId = Int32.Parse(text);
                    }

                    BrokerError error = new BrokerError();
                    error.Message    = frame.RemoveProperty("message");
                    answer.Exception = error;
                    Tracer.Debug("StompWireFormat - Received ERROR command: " + error.Message);
                    return(answer);
                }
            }
            else if (command == "MESSAGE")
            {
                Tracer.Debug("StompWireFormat - Received MESSAGE command");
                return(ReadMessage(frame));
            }

            Tracer.Error("Unknown command: " + frame.Command + " headers: " + frame.Properties);

            return(null);
        }