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

Oneway() public method

public Oneway ( Command command ) : void
command Command
return void
        public override void Oneway(Command command)
        {
            // Disable inactivity monitoring while processing a command.
            //synchronize this method - its not synchronized
            //further down the transport stack and gets called by more
            //than one thread  by this class
            lock(inWrite)
            {
                inWrite.Value = true;
                try
                {
                    if(failed.Value)
                    {
                        throw new IOException("Channel was inactive for too long: " + next.RemoteAddress.ToString());
                    }
                    if(command.IsWireFormatInfo)
                    {
                        lock(monitor)
                        {
                            localWireFormatInfo = command as WireFormatInfo;
                            StartMonitorThreads();
                        }
                    }
                    next.Oneway(command);
                }
                finally
                {
                    commandSent.Value = true;
                    inWrite.Value = false;
                }
            }
        }

Usage Example

        public void TestNonFailureSendCase()
        {
            InactivityMonitor monitor = new InactivityMonitor( this.transport );

            monitor.Exception += new ExceptionHandler(OnException);
            monitor.Command += new CommandHandler(OnCommand);
            monitor.Start();

            // Send the local one for the monitor to record.
            monitor.Oneway( this.localWireFormatInfo );

            ActiveMQMessage message = new ActiveMQMessage();
            for( int ix = 0; ix < 20; ++ix )
            {
                monitor.Oneway( message );
                Thread.Sleep( 500 );
                this.transport.InjectCommand( message );
                Thread.Sleep( 500 );
            }

            // Channel should have been inactive for to long.
            Assert.IsTrue( this.exceptions.Count == 0 );
        }
All Usage Examples Of Apache.NMS.ActiveMQ.Transport.InactivityMonitor::Oneway