This class make sure that the connection is still alive, by monitoring the reception of commands from the peer of the transport.
Inheritance: TransportFilter
Esempio n. 1
0
        public void TestCreate()
        {
            InactivityMonitor monitor = new InactivityMonitor( this.transport );

            Assert.IsTrue( monitor.InitialDelayTime == 0 );
            Assert.IsTrue( monitor.ReadCheckTime == 0 );
            Assert.IsTrue( monitor.WriteCheckTime == 0 );
            Assert.IsTrue( monitor.KeepAliveResponseRequired == false );
            Assert.IsTrue( monitor.IsDisposed == false );
        }
Esempio n. 2
0
        public void TestReadTimeout()
        {
            InactivityMonitor monitor = new InactivityMonitor( this.transport );

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

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

            Thread.Sleep( 2000 );

            // Should not have timed out on Read yet.
            Assert.IsTrue( this.exceptions.Count == 0 );

            Thread.Sleep( 5000 );

            // Channel should have been inactive for to long.
            Assert.IsTrue( this.exceptions.Count > 0 );
        }
Esempio n. 3
0
 public AsyncWriteTask(InactivityMonitor parent)
 {
     this.parent = parent;
 }
Esempio n. 4
0
 public AsyncSignalReadErrorkTask(InactivityMonitor parent, Uri remote)
 {
     this.parent = parent;
     this.remote = remote;
 }
Esempio n. 5
0
			public AsyncWriteTask(InactivityMonitor parent)
			{
				this.parent = parent;
			}
Esempio n. 6
0
			public AsyncSignalReadErrorkTask(InactivityMonitor parent, Uri remote)
			{
				this.parent = parent;
				this.remote = remote;
			}
Esempio n. 7
0
        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 );
        }
Esempio n. 8
0
        public void TestWriteMessageFail()
        {
            this.transport.FailOnKeepAliveInfoSends = true ;
            this.transport.NumSentKeepAliveInfosBeforeFail = 4;

            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 );

            Thread.Sleep( 2000 );

            ActiveMQMessage message = new ActiveMQMessage();
            this.transport.InjectCommand( message );

            Thread.Sleep( 2000 );

            // Should not have timed out on Read yet.
            Assert.IsTrue( this.exceptions.Count == 0 );

            for(int ix = 0; ix < 4; ix++)
            {
                this.transport.InjectCommand( message );
                Thread.Sleep( 2000 );
            }
			
            // Channel should have been inactive for to long.
            Assert.IsTrue( this.exceptions.Count > 0 );
        }