Skip to content
Permalink
Browse files
fix for: https://issues.apache.org/activemq/browse/AMQNET-260

Fixes both NMS.ActiveMQ and NMS.Stomp
  • Loading branch information
Timothy A. Bish committed Jul 9, 2010
1 parent 63ed445 commit 4f9ebdc62fa0351343c39cb8749884d1991a93ee
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 193 deletions.
@@ -48,7 +48,7 @@ public class Connection : IConnection
private PrefetchPolicy prefetchPolicy = new PrefetchPolicy();

private bool userSpecifiedClientID;
private TimeSpan requestTimeout;
private TimeSpan requestTimeout = NMSConstants.defaultRequestTimeout;
private readonly IList sessions = ArrayList.Synchronized(new ArrayList());
private readonly IDictionary dispatchers = Hashtable.Synchronized(new Hashtable());
private readonly object myLock = new object();
@@ -67,7 +67,6 @@ public class Connection : IConnection
public Connection(Uri connectionUri, ITransport transport, IdGenerator clientIdGenerator)
{
this.brokerUri = connectionUri;
this.requestTimeout = transport.RequestTimeout;
this.clientIdGenerator = clientIdGenerator;

this.transport = transport;
@@ -46,6 +46,7 @@ public class ConnectionFactory : IConnectionFactory
private bool alwaysSyncSend;
private bool sendAcksAsync=true;
private bool dispatchAsync=true;
private TimeSpan requestTimeout = NMSConstants.defaultRequestTimeout;
private AcknowledgementMode acknowledgementMode = AcknowledgementMode.AutoAcknowledge;

private IRedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
@@ -231,6 +232,12 @@ public bool DispatchAsync
set { this.dispatchAsync = value; }
}

public int RequestTimeout
{
get { return (int) this.requestTimeout.TotalMilliseconds; }
set { this.requestTimeout = TimeSpan.FromMilliseconds(value); }
}

public AcknowledgementMode AcknowledgementMode
{
get { return acknowledgementMode; }
@@ -301,6 +308,7 @@ protected virtual void ConfigureConnection(Connection connection)
connection.SendAcksAsync = this.SendAcksAsync;
connection.DispatchAsync = this.DispatchAsync;
connection.AcknowledgementMode = this.acknowledgementMode;
connection.RequestTimeout = this.requestTimeout;
connection.RedeliveryPolicy = this.redeliveryPolicy.Clone() as IRedeliveryPolicy;
connection.PrefetchPolicy = this.prefetchPolicy.Clone() as PrefetchPolicy;
}
@@ -66,7 +66,6 @@ public class FailoverTransport : ICompositeTransport, IComparable
private int reconnectDelay = 10;
private Exception connectionFailure;
private bool firstConnection = true;
private TimeSpan requestTimeout = NMSConstants.defaultRequestTimeout;
private volatile Exception failure;
private readonly object mutex = new object();

@@ -156,12 +155,6 @@ public int Timeout
set { this.timeout = value; }
}

public TimeSpan RequestTimeout
{
get { return requestTimeout; }
set { requestTimeout = value; }
}

public int InitialReconnectDelay
{
get { return initialReconnectDelay; }
@@ -28,7 +28,7 @@ namespace Apache.NMS.Stomp.Transport
/// </summary>
public class FutureResponse
{
private static TimeSpan maxWait = TimeSpan.FromMilliseconds(Timeout.Infinite);
private TimeSpan maxWait = TimeSpan.FromMilliseconds(Timeout.Infinite);
public TimeSpan ResponseTimeout
{
get { return maxWait; }
@@ -48,30 +48,25 @@ public Response Response
// Blocks the caller until a value has been set
get
{
bool waitForResponse = false;

lock(latch)
{
if(null == response)
if(null != response)
{
waitForResponse = true;
return response;
}
}

if(waitForResponse)
try
{
try
{
if(!latch.await(maxWait))
{
// TODO: Throw timeout exception?
}
}
catch (Exception e)
if(!latch.await(maxWait))
{
Tracer.Error("Caught while waiting on monitor: " + e);
// TODO: Throw timeout exception?
}
}
catch (Exception e)
{
Tracer.Error("Caught while waiting on monitor: " + e);
}

lock(latch)
{
@@ -96,16 +96,6 @@ public interface ITransport : IStartable, IDisposable, IStoppable
/// A <see cref="System.Object"/>
/// </returns>
Object Narrow(Type type);

/// <value>
/// The time that the Transport waits before considering a request to have
/// failed and throwing an exception.
/// </value>
TimeSpan RequestTimeout
{
get;
set;
}

CommandHandler Command
{

0 comments on commit 4f9ebdc

Please sign in to comment.