Author: jgomes
Date: Tue Jun  3 11:36:18 2008
New Revision: 662856

URL: http://svn.apache.org/viewvc?rev=662856&view=rev
Log:
Refactor the transport request API to include optional timeout value on a 
single-call basis without changing the default timeout.  Also including patch 
contribution from Anthony Enache for [AMQNET-87].
Fixes [AMQNET-87,89]. (See 
https://issues.apache.org/activemq/browse/AMQNET-87,89)

Modified:
    
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs
    
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Dispatcher.cs
    
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/FutureResponse.cs
    
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ITransport.cs
    
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/MutexTransport.cs
    
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs
    
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.cs
    
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs
    
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/TransportFilter.cs
    
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/WireFormatNegotiator.cs
    
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/sandbox/alternative-threading/FutureResponse.cs
    
activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/CountDownLatch.cs

Modified: 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs?rev=662856&r1=662855&r2=662856&view=diff
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs
 (original)
+++ 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Connection.cs
 Tue Jun  3 11:36:18 2008
@@ -36,6 +36,7 @@
                private WireFormatInfo brokerWireFormatInfo; // from broker
                private readonly IList sessions = ArrayList.Synchronized(new 
ArrayList());
                private bool asyncSend = false;
+               private bool asyncClose = true;
                private bool connected = false;
                private bool closed = false;
                private bool closing = false;
@@ -62,7 +63,6 @@
 
                public event ExceptionListener ExceptionListener;
 
-
                #region Properties
 
                /// <summary>
@@ -75,6 +75,18 @@
                }
 
                /// <summary>
+               /// This property indicates whether or not async close is 
enabled.
+               /// When the connection is closed, it will either send a 
synchronous
+               /// DisposeOf command to the broker and wait for confirmation 
(if true),
+               /// or it will send the DisposeOf command asynchronously.
+               /// </summary>
+               public bool AsyncClose
+               {
+                       get { return asyncClose; }
+                       set { asyncClose = value; }
+               }
+
+               /// <summary>
                /// This property sets the acknowledgment mode for the 
connection.
                /// The URI parameter connection.ackmode can be set to a string 
value
                /// that maps to the enumeration value.
@@ -280,10 +292,17 @@
                /// <summary>
                /// Performs a synchronous request-response with the broker
                /// </summary>
+               /// 
+
                public Response SyncRequest(Command command)
                {
+                       return SyncRequest(command, transport.RequestTimeout);
+               }
+
+               public Response SyncRequest(Command command, TimeSpan 
requestTimeout)
+               {
                        CheckConnected();
-                       Response response = transport.Request(command);
+                       Response response = transport.Request(command, 
requestTimeout);
                        if(response is ExceptionResponse)
                        {
                                ExceptionResponse exceptionResponse = 
(ExceptionResponse) response;
@@ -303,10 +322,24 @@
                {
                        RemoveInfo command = new RemoveInfo();
                        command.ObjectId = objectId;
-                       // Ensure that the object is disposed to avoid 
potential race-conditions
-                       // of trying to re-create the same object in the broker 
faster than
-                       // the broker can dispose of the object.
-                       SyncRequest(command);
+                       if(asyncClose)
+                       {
+                               OneWay(command);
+                       }
+                       else
+                       {
+                               // Ensure that the object is disposed to avoid 
potential race-conditions
+                               // of trying to re-create the same object in 
the broker faster than
+                               // the broker can dispose of the object.  Allow 
up to 5 seconds to process.
+                               try
+                               {
+                                       SyncRequest(command, 
TimeSpan.FromSeconds(5));
+                               }
+                               catch // (BrokerException)
+                               {
+                                       // Ignore exceptions while shutting 
down.
+                               }
+                       }
                }
 
                /// <summary>

Modified: 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Dispatcher.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Dispatcher.cs?rev=662856&r1=662855&r2=662856&view=diff
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Dispatcher.cs
 (original)
+++ 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Dispatcher.cs
 Tue Jun  3 11:36:18 2008
@@ -133,7 +133,7 @@
 
             while (!bClosed && rc == null)
             {
-                if( !messageReceivedEventHandle.WaitOne((int) 
timeout.TotalMilliseconds, false))
+                if( !messageReceivedEventHandle.WaitOne(timeout, false))
                 {
                     break;
                 }

Modified: 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/FutureResponse.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/FutureResponse.cs?rev=662856&r1=662855&r2=662856&view=diff
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/FutureResponse.cs
 (original)
+++ 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/FutureResponse.cs
 Tue Jun  3 11:36:18 2008
@@ -22,15 +22,13 @@
 
 namespace Apache.NMS.ActiveMQ.Transport
 {
-
        /// <summary>
        /// Handles asynchronous responses
        /// </summary>
        public class FutureResponse
        {
-
-               private static int maxWait = -1;
-               public int Timeout
+               private static TimeSpan maxWait = 
TimeSpan.FromMilliseconds(Timeout.Infinite);
+               public TimeSpan ResponseTimeout
                {
                        get { return maxWait; }
                        set { maxWait = value; }

Modified: 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ITransport.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ITransport.cs?rev=662856&r1=662855&r2=662856&view=diff
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ITransport.cs
 (original)
+++ 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ITransport.cs
 Tue Jun  3 11:36:18 2008
@@ -31,15 +31,24 @@
         void Oneway(Command command);
         
         FutureResponse AsyncRequest(Command command);
-        
+
+               TimeSpan RequestTimeout
+               {
+                       get;
+                       set;
+               }
+
         Response Request(Command command);
+               Response Request(Command command, TimeSpan timeout);
         
-        CommandHandler Command {
+        CommandHandler Command
+               {
             get;
             set;
         }
                
-        ExceptionHandler Exception {
+        ExceptionHandler Exception
+               {
             get;
             set;
         }

Modified: 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/MutexTransport.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/MutexTransport.cs?rev=662856&r1=662855&r2=662856&view=diff
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/MutexTransport.cs
 (original)
+++ 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/MutexTransport.cs
 Tue Jun  3 11:36:18 2008
@@ -20,22 +20,20 @@
 
 namespace Apache.NMS.ActiveMQ.Transport
 {
-       
     /// <summary>
-    /// A Transport which gaurds access to the next transport using a mutex.
+    /// A Transport which guards access to the next transport using a mutex.
     /// </summary>
     public class MutexTransport : TransportFilter
     {
-
         private readonly object transmissionLock = new object();
 
-        public MutexTransport(ITransport next) : base(next) {
+        public MutexTransport(ITransport next) : base(next)
+               {
         }
-
         
         public override void Oneway(Command command)
         {
-            lock (transmissionLock)
+            lock(transmissionLock)
             {
                 this.next.Oneway(command);
             }
@@ -43,28 +41,26 @@
 
         public override FutureResponse AsyncRequest(Command command)
         {
-            lock (transmissionLock)
+            lock(transmissionLock)
             {
                 return base.AsyncRequest(command);
             }
         }
 
-        public override Response Request(Command command)
-        {
-            lock (transmissionLock)
-            {
-                return base.Request(command);
-            }
-        }
+               public override Response Request(Command command, TimeSpan 
timeout)
+               {
+                       lock(transmissionLock)
+                       {
+                               return base.Request(command, timeout);
+                       }
+               }
 
-        public override void Dispose()
+               public override void Dispose()
         {
-            lock (transmissionLock)
+            lock(transmissionLock)
             {
                 base.Dispose();
             }
         }
-
     }
 }
-

Modified: 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs?rev=662856&r1=662855&r2=662856&view=diff
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs
 (original)
+++ 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs
 Tue Jun  3 11:36:18 2008
@@ -24,84 +24,101 @@
 
 namespace Apache.NMS.ActiveMQ.Transport
 {
-       
-    /// <summary>
-    /// A Transport which gaurds access to the next transport using a mutex.
-    /// </summary>
-    public class ResponseCorrelator : TransportFilter
-    {
+       /// <summary>
+       /// A Transport that correlates asynchronous send/receive messages into 
single request/response.
+       /// </summary>
+       public class ResponseCorrelator : TransportFilter
+       {
                private readonly IDictionary requestMap = 
Hashtable.Synchronized(new Hashtable());
                private readonly Object mutex = new Object();
-        private short nextCommandId;
-        private int requestTimeout = -1;
+               private short nextCommandId;
 
-        public ResponseCorrelator(ITransport next, int requestTimeout) : 
base(next)
+               public ResponseCorrelator(ITransport next) : base(next)
                {
-                       this.requestTimeout = requestTimeout;
-        }
+               }
 
-        short GetNextCommandId()
+               protected override void OnException(ITransport sender, 
Exception command)
                {
-            lock(mutex)
+                       base.OnException(sender, command);
+
+                       foreach(DictionaryEntry entry in requestMap)
+                       {
+                               FutureResponse value = (FutureResponse) 
entry.Value;
+                               ExceptionResponse response = new 
ExceptionResponse();
+                               BrokerError error = new BrokerError();
+
+                               error.Message = command.Message;
+                               response.Exception = error;
+                               value.Response = response;
+                       }
+
+                       requestMap.Clear();
+               }
+
+               short GetNextCommandId()
+               {
+                       lock(mutex)
                        {
-                return ++nextCommandId;
-            }
-        }
+                               return ++nextCommandId;
+                       }
+               }
 
-        public override void Oneway(Command command)
-        {
+               public override void Oneway(Command command)
+               {
                        int commandId = GetNextCommandId();
 
-            command.CommandId = commandId;
-            command.ResponseRequired = false;
-            next.Oneway(command);
-        }
+                       command.CommandId = commandId;
+                       command.ResponseRequired = false;
+                       next.Oneway(command);
+               }
 
-        public override FutureResponse AsyncRequest(Command command)
-        {
+               public override FutureResponse AsyncRequest(Command command)
+               {
                        int commandId = GetNextCommandId();
 
-               command.CommandId = commandId;
-            command.ResponseRequired = true;
-            FutureResponse future = new FutureResponse();
-            requestMap[commandId] = future;
+                       command.CommandId = commandId;
+                       command.ResponseRequired = true;
+                       FutureResponse future = new FutureResponse();
+                       requestMap[commandId] = future;
                        next.Oneway(command);
-            return future;
+                       return future;
 
-        }
+               }
+
+               public override Response Request(Command command, TimeSpan 
timeout)
+               {
+                       FutureResponse future = AsyncRequest(command);
+                       future.ResponseTimeout = timeout;
+                       Response response = future.Response;
+
+                       if(response != null && response is ExceptionResponse)
+                       {
+                               ExceptionResponse er = (ExceptionResponse) 
response;
+                               BrokerError brokerError = er.Exception;
 
-        public override Response Request(Command command)
-        {
-            FutureResponse future = AsyncRequest(command);
-            future.Timeout = requestTimeout;
-            Response response = future.Response;
-            if (response != null && response is ExceptionResponse)
-            {
-                ExceptionResponse er = (ExceptionResponse) response;
-                BrokerError brokerError = er.Exception;
                                if (brokerError == null)
                                {
-                       throw new BrokerException();
+                                       throw new BrokerException();
                                }
                                else
                                {
-                       throw new BrokerException(brokerError);
+                                       throw new BrokerException(brokerError);
                                }
-            }
-            return response;
-        }
-
-        protected override void OnCommand(ITransport sender, Command command)
-        {
-            if(command is Response)
+                       }
+
+                       return response;
+               }
+
+               protected override void OnCommand(ITransport sender, Command 
command)
+               {
+                       if(command is Response)
                        {
-                Response response = (Response) command;
+                               Response response = (Response) command;
                                int correlationId = response.CorrelationId;
-
                                FutureResponse future = (FutureResponse) 
requestMap[correlationId];
-                
+                               
                                if(future != null)
-                {
+                               {
                                        requestMap.Remove(correlationId);
                                        future.Response = response;
 
@@ -117,17 +134,18 @@
                                {
                                        Tracer.Error("Unknown response ID: " + 
response.CommandId + " for response: " + response);
                                }
-            }
-            else if(command is ShutdownInfo)
-            {
-                // lets shutdown
-                this.commandHandler(sender, command);
-            }
+                       }
+                       else if(command is ShutdownInfo)
+                       {
+                               // lets shutdown
+                               this.commandHandler(sender, command);
+                       }
                        else
                        {
-                this.commandHandler(sender, command);
-            }
-        }
-    }
+                               this.commandHandler(sender, command);
+                       }
+               }
+       }
 }
 
+

Modified: 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.cs?rev=662856&r1=662855&r2=662856&view=diff
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.cs
 (original)
+++ 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransport.cs
 Tue Jun  3 11:36:18 2008
@@ -39,6 +39,7 @@
                private Thread readThread;
         private bool started;
         private Util.AtomicBoolean closed = new Util.AtomicBoolean(false);
+               private TimeSpan maxWait = 
TimeSpan.FromMilliseconds(Timeout.Infinite);
         
         private CommandHandler commandHandler;
         private ExceptionHandler exceptionHandler;
@@ -137,13 +138,27 @@
         {
             throw new NotImplementedException("Use a ResponseCorrelator if you 
want to issue AsyncRequest calls");
         }
-        
-        public Response Request(Command command)
+
+               /// <summary>
+               /// Property RequestTimeout
+               /// </summary>
+               public TimeSpan RequestTimeout
+               {
+                       get { return this.maxWait; }
+                       set { this.maxWait = value; }
+               }
+
+               public Response Request(Command command)
         {
             throw new NotImplementedException("Use a ResponseCorrelator if you 
want to issue Request calls");
         }
 
-        public void Close()
+               public Response Request(Command command, TimeSpan timeout)
+               {
+                       throw new NotImplementedException("Use a 
ResponseCorrelator if you want to issue Request calls");
+               }
+               
+               public void Close()
         {
                        if(closed.CompareAndSet(false, true))
                        {

Modified: 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs?rev=662856&r1=662855&r2=662856&view=diff
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs
 (original)
+++ 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Tcp/TcpTransportFactory.cs
 Tue Jun  3 11:36:18 2008
@@ -23,6 +23,7 @@
 using Apache.NMS.ActiveMQ.Transport.Stomp;
 using Apache.NMS;
 using Apache.NMS.Util;
+using System.Threading;
 
 namespace Apache.NMS.ActiveMQ.Transport.Tcp
 {
@@ -48,11 +49,11 @@
                        set { wireFormat = value; }
                }
 
-               private int requestTimeout = -1;
+               private TimeSpan requestTimeout = 
TimeSpan.FromMilliseconds(Timeout.Infinite);
                public int RequestTimeout
                {
-                       get { return requestTimeout; }
-                       set { requestTimeout = value; }
+                       get { return (int) requestTimeout.TotalMilliseconds; }
+                       set { requestTimeout = 
TimeSpan.FromMilliseconds(value); }
                }
 
                #endregion
@@ -85,7 +86,8 @@
                        }
 
                        transport = new MutexTransport(transport);
-                       transport = new ResponseCorrelator(transport, 
requestTimeout);
+                       transport = new ResponseCorrelator(transport);
+                       transport.RequestTimeout = this.requestTimeout;
 
                        return transport;
                }

Modified: 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/TransportFilter.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/TransportFilter.cs?rev=662856&r1=662855&r2=662856&view=diff
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/TransportFilter.cs
 (original)
+++ 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/TransportFilter.cs
 Tue Jun  3 11:36:18 2008
@@ -20,7 +20,6 @@
 
 namespace Apache.NMS.ActiveMQ.Transport
 {
-       
        /// <summary>
        /// Used to implement a filter on the transport layer.
        /// </summary>
@@ -30,21 +29,23 @@
                protected CommandHandler commandHandler;
                protected ExceptionHandler exceptionHandler;
                
-               public TransportFilter(ITransport next) {
+               public TransportFilter(ITransport next)
+               {
                        this.next = next;
                        this.next.Command = new CommandHandler(OnCommand);
                        this.next.Exception = new ExceptionHandler(OnException);
                }
                
-               protected virtual void OnCommand(ITransport sender, Command 
command) {
+               protected virtual void OnCommand(ITransport sender, Command 
command)
+               {
                        this.commandHandler(sender, command);
                }
                
-               protected virtual void OnException(ITransport sender, Exception 
command) {
+               protected virtual void OnException(ITransport sender, Exception 
command)
+               {
                        this.exceptionHandler(sender, command);
                }
                
-               
                /// <summary>
                /// Method Oneway
                /// </summary>
@@ -63,7 +64,16 @@
                {
                        return this.next.AsyncRequest(command);
                }
-               
+
+               /// <summary>
+               /// Property RequestTimeout
+               /// </summary>
+               public TimeSpan RequestTimeout
+               {
+                       get { return this.next.RequestTimeout; }
+                       set { this.next.RequestTimeout = value; }
+               }
+
                /// <summary>
                /// Method Request
                /// </summary>
@@ -71,18 +81,35 @@
                /// <param name="command">A  Command</param>
                public virtual Response Request(Command command)
                {
-                       return this.next.Request(command);
+                       return Request(command, RequestTimeout);
                }
-               
+
+               /// <summary>
+               /// Method Request with time out for Response.
+               /// </summary>
+               /// <returns>A Response</returns>
+               /// <param name="command">A  Command</param>
+               /// <param name="timeout">Timeout in milliseconds</param>
+               public virtual Response Request(Command command, TimeSpan 
timeout)
+               {
+                       return this.next.Request(command, timeout);
+               }
+
                /// <summary>
                /// Method Start
                /// </summary>
                public virtual void Start()
                {
-                       if( commandHandler == null )
+                       if(commandHandler == null)
+                       {
                                throw new InvalidOperationException ("command 
cannot be null when Start is called.");
-                       if( exceptionHandler == null )
+                       }
+
+                       if(exceptionHandler == null)
+                       {
                                throw new InvalidOperationException ("exception 
cannot be null when Start is called.");
+                       }
+
                        this.next.Start();
                }
 
@@ -91,10 +118,7 @@
                /// </summary>
                public bool IsStarted
                {
-                       get
-                       {
-                               return this.next.IsStarted;
-                       }
+                       get { return this.next.IsStarted; }
                }
 
                /// <summary>
@@ -105,12 +129,14 @@
                        this.next.Dispose();
                }
                
-               public CommandHandler Command {
+               public CommandHandler Command
+               {
             get { return commandHandler; }
             set { this.commandHandler = value; }
         }
                
-        public  ExceptionHandler Exception {
+        public  ExceptionHandler Exception
+               {
             get { return exceptionHandler; }
             set { this.exceptionHandler = value; }
         }

Modified: 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/WireFormatNegotiator.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/WireFormatNegotiator.cs?rev=662856&r1=662855&r2=662856&view=diff
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/WireFormatNegotiator.cs
 (original)
+++ 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/WireFormatNegotiator.cs
 Tue Jun  3 11:36:18 2008
@@ -31,7 +31,7 @@
     public class WireFormatNegotiator : TransportFilter
     {
         private OpenWireFormat wireFormat;
-        private int negotiateTimeout=15000;
+        private TimeSpan negotiateTimeout = TimeSpan.FromSeconds(15);
     
         private AtomicBoolean firstStart=new AtomicBoolean(true);
         private CountDownLatch readyCountDownLatch = new CountDownLatch(1);
@@ -43,7 +43,8 @@
             this.wireFormat = wireFormat;
         }
         
-        public override void Start() {
+        public override void Start()
+        {
             base.Start();
             if (firstStart.CompareAndSet(true, false))
             {
@@ -58,7 +59,8 @@
             }
         }
         
-        public override void Dispose() {
+        public override void Dispose()
+        {
                base.Dispose();
             readyCountDownLatch.countDown();
         }
@@ -66,7 +68,7 @@
         public override void Oneway(Command command)
         {
             if (!readyCountDownLatch.await(negotiateTimeout))
-                throw new IOException("Wire format negociation timeout: peer 
did not send his wire format.");
+                throw new IOException("Wire format negotiation timeout: peer 
did not send his wire format.");
             next.Oneway(command);
         }
 

Modified: 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/sandbox/alternative-threading/FutureResponse.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/sandbox/alternative-threading/FutureResponse.cs?rev=662856&r1=662855&r2=662856&view=diff
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/sandbox/alternative-threading/FutureResponse.cs
 (original)
+++ 
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/sandbox/alternative-threading/FutureResponse.cs
 Tue Jun  3 11:36:18 2008
@@ -28,7 +28,7 @@
        public class FutureResponse 
     {
            
-        private static int maxWait = -1;
+        private static TimeSpan maxWait = 
TimeSpan.FromMilliseconds(Timeout.Infinite);
 
         private readonly CountDownLatch latch = new CountDownLatch(1);
         private Response response;

Modified: 
activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/CountDownLatch.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/CountDownLatch.cs?rev=662856&r1=662855&r2=662856&view=diff
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/CountDownLatch.cs
 (original)
+++ 
activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/CountDownLatch.cs
 Tue Jun  3 11:36:18 2008
@@ -55,7 +55,7 @@
                        }
                }
 
-               public bool await(int timeout)
+               public bool await(TimeSpan timeout)
                {
                        return mutex.WaitOne(timeout, false);
                }


Reply via email to