Apache.NMS.ActiveMQ.Transport.Mock.MockTransport.Oneway C# (CSharp) Method

Oneway() public method

public Oneway ( Command command ) : void
command Command
return void
        public void Oneway(Command command)
        {
            Tracer.Debug("MockTransport sending oneway Command: " + command.ToString());

            if(command.IsMessage)
            {
                this.numSentMessages++;

                if(this.failOnSendMessage && this.numSentMessages > this.numSentMessagesBeforeFail)
                {
                    Tracer.Debug("MockTransport Oneway send, failing as per configuration.");
                    throw new IOException("Failed to Send Message.");
                }
            }

            if(command.IsKeepAliveInfo)
            {
                this.numSentKeppAliveInfos++;

                if(this.failOnKeepAliveInfoSends && this.numSentKeppAliveInfos > this.numSentKeepAliveInfosBeforeFail)
                {
                    Tracer.Debug("MockTransport Oneway send, failing as per configuration.");
                    throw new IOException("Failed to Send Message.");
                }
            }

            // Process and send any new Commands back.
            List<Command> results = new List<Command>();

            // Let the Response Builder give us the Commands to send to the Client App.
            if(command.IsMessage)
            {
                if(this.respondToMessages && this.NumMessagesToRespondTo < this.numMessagesRespondedTo)
                {
                    results = this.responseBuilder.BuildIncomingCommands(command);
                    this.numMessagesRespondedTo++;
                }
            }
            else
            {
                results = this.responseBuilder.BuildIncomingCommands(command);
            }

            lock(this.receiveQueue)
            {
                foreach(Command result in results)
                {
                    this.receiveQueue.Enqueue(result);
                }
            }

            this.asyncResponseTask.Wakeup();

            // Send the Command to the Outgoing Command Snoop Hook.
            if(this.OutgoingCommand != null)
            {
                Tracer.Debug("MockTransport Oneway, Notifying Outgoing linstener.");
                this.OutgoingCommand(this, command);
            }
        }