示例#1
0
        //
        // Write a object instance to data output stream
        //
        public override void LooseMarshal(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut)
        {
            ProducerAck info = (ProducerAck)o;

            base.LooseMarshal(wireFormat, o, dataOut);
            LooseMarshalNestedObject(wireFormat, (DataStructure)info.ProducerId, dataOut);
            dataOut.Write(info.Size);
        }
示例#2
0
        //
        // Un-marshal an object instance from the data input stream
        //
        public override void LooseUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn)
        {
            base.LooseUnmarshal(wireFormat, o, dataIn);

            ProducerAck info = (ProducerAck)o;

            info.ProducerId = (ProducerId)LooseUnmarshalNestedObject(wireFormat, dataIn);
            info.Size       = dataIn.ReadInt32();
        }
示例#3
0
        //
        // Write a object instance to data output stream
        //
        public override void TightMarshal2(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut, BooleanStream bs)
        {
            base.TightMarshal2(wireFormat, o, dataOut, bs);

            ProducerAck info = (ProducerAck)o;

            TightMarshalNestedObject2(wireFormat, (DataStructure)info.ProducerId, dataOut, bs);
            dataOut.Write(info.Size);
        }
示例#4
0
        //
        // Un-marshal an object instance from the data input stream
        //
        public override void TightUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn, BooleanStream bs)
        {
            base.TightUnmarshal(wireFormat, o, dataIn, bs);

            ProducerAck info = (ProducerAck)o;

            info.ProducerId = (ProducerId)TightUnmarshalNestedObject(wireFormat, dataIn, bs);
            info.Size       = dataIn.ReadInt32();
        }
        public void OnProducerAck(ProducerAck ack)
        {
            Tracer.Debug("Received ProducerAck for Message of Size = {" + ack.Size + "}");

            if (this.usage != null)
            {
                this.usage.DecreaseUsage(ack.Size);
            }
        }
示例#6
0
        //
        // Write the booleans that this object uses to a BooleanStream
        //
        public override int TightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs)
        {
            ProducerAck info = (ProducerAck)o;

            int rc = base.TightMarshal1(wireFormat, o, bs);

            rc += TightMarshalNestedObject1(wireFormat, (DataStructure)info.ProducerId, bs);

            return(rc + 4);
        }
示例#7
0
        internal void OnProducerAck(ProducerAck ack)
        {
            if (Tracer.IsDebugEnabled)
            {
                Tracer.Debug("Received ProducerAck for Message of Size = {" + ack.Size + "}");
            }

            if (this.usage != null)
            {
                this.usage.DecreaseUsage(ack.Size);
            }
        }
示例#8
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);
            }
        }
示例#9
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 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);
            }
        }
示例#10
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)
            {
                // Only terminate the connection if the transport we use is not fault
                // tolerant otherwise we let the transport deal with the broker closing
                // our connection and deal with IOException if it is sent to use.
                if (!closing.Value && !closed.Value && this.transport != null && !this.transport.IsFaultTolerant)
                {
                    OnException(new NMSException("Broker closed this connection via Shutdown command."));
                }
            }
            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.DebugFormat("Connection[{0}]: Received a new ProducerAck -> ",
                                               this.ConnectionId, 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;
                        }
                    }

                    Tracer.ErrorFormat("Connection[{0}]: ConnectionError: " + message + " : " + cause, this.ConnectionId);
                    OnAsyncException(new NMSConnectionException(message, cause));
                }
            }
            else
            {
                Tracer.ErrorFormat("Connection[{0}]: Unknown command: " + command, this.ConnectionId);
            }
        }
 public virtual Response processProducerAck(ProducerAck ack)
 {
     return(null);
 }