Author: tabish
Date: Wed Dec 29 13:35:18 2010
New Revision: 1053632
URL: http://svn.apache.org/viewvc?rev=1053632&view=rev
Log:
Apply patch for: https://issues.apache.org/jira/browse/AMQNET-300
Modified:
activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs
Modified:
activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs
URL:
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs?rev=1053632&r1=1053631&r2=1053632&view=diff
==============================================================================
---
activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs
(original)
+++
activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs
Wed Dec 29 13:35:18 2010
@@ -61,6 +61,7 @@ namespace Apache.NMS.Stomp.Transport.Fai
private bool useExponentialBackOff = true;
private bool randomize = true;
private int maxReconnectAttempts;
+ private int startupMaxReconnectAttempts;
private int connectFailures;
private int reconnectDelay = 10;
private Exception connectionFailure;
@@ -196,6 +197,12 @@ namespace Apache.NMS.Stomp.Transport.Fai
set { maxReconnectAttempts = value; }
}
+ public int StartupMaxReconnectAttempts
+ {
+ get { return startupMaxReconnectAttempts; }
+ set { startupMaxReconnectAttempts = value; }
+ }
+
public bool Randomize
{
get { return randomize; }
@@ -824,7 +831,17 @@ namespace Apache.NMS.Stomp.Transport.Fai
}
}
- if(MaxReconnectAttempts > 0 && ++connectFailures >=
MaxReconnectAttempts)
+ int maxAttempts = 0;
+ if( firstConnection ) {
+ if( StartupMaxReconnectAttempts != 0 ) {
+ maxAttempts = StartupMaxReconnectAttempts;
+ }
+ }
+ if( maxAttempts == 0 ) {
+ maxAttempts = MaxReconnectAttempts;
+ }
+
+ if(maxAttempts > 0 && ++connectFailures >= maxAttempts)
{
Tracer.ErrorFormat("Failed to connect to transport
after {0} attempt(s)", connectFailures);
connectionFailure = Failure;