activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r1705384 - in /activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x: ./ src/main/csharp/ConnectionFactory.cs src/main/csharp/IntrospectionSupport.cs vs2008-ems.csproj
Date Fri, 25 Sep 2015 23:20:28 GMT
Author: jgomes
Date: Fri Sep 25 23:20:28 2015
New Revision: 1705384

URL: http://svn.apache.org/viewvc?rev=1705384&view=rev
Log:
Merged revision(s) 1705382 from activemq/activemq-dotnet/Apache.NMS.EMS/trunk:
Add calls to TIBCO API to turn on failover mode.
Add support for URL parameters:
   connection.ExceptionOnFTEvents
   connection.ExceptionOnFTSwitch
   connection.ConnAttemptCount
   connection.ConnAttemptDelay
   connection.ConnAttemptTimeout
   connection.ReconnAttemptCount
   connection.ReconnAttemptDelay
   connection.ReconnAttemptTimeout

Fixes [AMQNET-511]. (See https://issues.apache.org/jira/browse/AMQNET-511)

Added:
    activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x/src/main/csharp/IntrospectionSupport.cs
      - copied unchanged from r1705382, activemq/activemq-dotnet/Apache.NMS.EMS/trunk/src/main/csharp/IntrospectionSupport.cs
Modified:
    activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x/   (props changed)
    activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x/src/main/csharp/ConnectionFactory.cs
    activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x/vs2008-ems.csproj   (contents,
props changed)

Propchange: activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 25 23:20:28 2015
@@ -1 +1,2 @@
 /activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.5.x:1172914
+/activemq/activemq-dotnet/Apache.NMS.EMS/trunk:1705382

Modified: activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x/src/main/csharp/ConnectionFactory.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x/src/main/csharp/ConnectionFactory.cs?rev=1705384&r1=1705383&r2=1705384&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x/src/main/csharp/ConnectionFactory.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x/src/main/csharp/ConnectionFactory.cs
Fri Sep 25 23:20:28 2015
@@ -17,7 +17,10 @@
 
 using System;
 using System.Collections;
+using System.Collections.Specialized;
+using Apache.NMS.EMS.Util;
 using Apache.NMS.Policies;
+using Apache.NMS.Util;
 
 namespace Apache.NMS.EMS
 {
@@ -30,6 +33,14 @@ namespace Apache.NMS.EMS
 		private Uri brokerUri;
 		private string clientId;
 		private Hashtable properties;
+		private bool exceptionOnFTEvents = true;
+		private bool exceptionOnFTSwitch = true;
+		private int connAttemptCount = Int32.MaxValue;   // Infinite
+		private int connAttemptDelay = 30000;            // 30 seconds
+		private int connAttemptTimeout = 5000;           // 5 seconds
+		private int reconnAttemptCount = Int32.MaxValue; // Infinite
+		private int reconnAttemptDelay = 30000;          // 30 seconds
+		private int reconnAttemptTimeout = 5000;         // 5 seconds
 
 		private IRedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
 
@@ -38,6 +49,7 @@ namespace Apache.NMS.EMS
 			try
 			{
 				this.tibcoConnectionFactory = new TIBCO.EMS.ConnectionFactory();
+				ConfigureConnectionFactory();
 			}
 			catch(Exception ex)
 			{
@@ -77,10 +89,11 @@ namespace Apache.NMS.EMS
 		{
 			try
 			{
-				this.tibcoConnectionFactory = new TIBCO.EMS.ConnectionFactory(serverUrl.AbsolutePath,
clientId, properties);
-				this.brokerUri = serverUrl;
+				this.brokerUri = ParseUriProperties(serverUrl);
+				this.tibcoConnectionFactory = new TIBCO.EMS.ConnectionFactory(TrimParens(this.brokerUri.AbsolutePath),
clientId, properties);
 				this.clientId = clientId;
 				this.properties = properties;
+				ConfigureConnectionFactory();
 			}
 			catch(Exception ex)
 			{
@@ -91,6 +104,22 @@ namespace Apache.NMS.EMS
 			VerifyConnectionFactory();
 		}
 
+		private void ConfigureConnectionFactory()
+		{
+			TIBCO.EMS.Tibems.SetExceptionOnFTEvents(this.ExceptionOnFTEvents);
+			TIBCO.EMS.Tibems.SetExceptionOnFTSwitch(this.ExceptionOnFTSwitch);
+
+			// Set the initial connection retry settings.
+			this.tibcoConnectionFactory.SetConnAttemptCount(this.ConnAttemptCount);
+			this.tibcoConnectionFactory.SetConnAttemptDelay(this.ConnAttemptDelay);
+			this.tibcoConnectionFactory.SetConnAttemptTimeout(this.ConnAttemptTimeout);
+
+			// Set the failover reconnect retry settings
+			this.tibcoConnectionFactory.SetReconnAttemptCount(this.ReconnAttemptCount);
+			this.tibcoConnectionFactory.SetReconnAttemptDelay(this.ReconnAttemptDelay);
+			this.tibcoConnectionFactory.SetReconnAttemptTimeout(this.ReconnAttemptTimeout);
+		}
+
 		private void VerifyConnectionFactory()
 		{
 			if(null == this.tibcoConnectionFactory)
@@ -99,6 +128,58 @@ namespace Apache.NMS.EMS
 			}
 		}
 
+		#region Connection Factory Properties (configure via URL parameters)
+
+		public bool ExceptionOnFTEvents
+		{
+			get { return this.exceptionOnFTEvents; }
+			set { this.exceptionOnFTEvents = value; }
+		}
+
+		public bool ExceptionOnFTSwitch
+		{
+			get { return this.exceptionOnFTSwitch; }
+			set { this.exceptionOnFTSwitch = value; }
+		}
+
+		public int ConnAttemptCount
+		{
+			get { return this.connAttemptCount; }
+			set { this.connAttemptCount = value; }
+		}
+
+		public int ConnAttemptDelay
+		{
+			get { return this.connAttemptDelay; }
+			set { this.connAttemptDelay = value; }
+		}
+
+		public int ConnAttemptTimeout
+		{
+			get { return this.connAttemptTimeout; }
+			set { this.connAttemptTimeout = value; }
+		}
+
+		public int ReconnAttemptCount
+		{
+			get { return this.reconnAttemptCount; }
+			set { this.reconnAttemptCount = value; }
+		}
+
+		public int ReconnAttemptDelay
+		{
+			get { return this.reconnAttemptDelay; }
+			set { this.reconnAttemptDelay = value; }
+		}
+
+		public int ReconnAttemptTimeout
+		{
+			get { return this.reconnAttemptTimeout; }
+			set { this.reconnAttemptTimeout = value; }
+		}
+
+		#endregion
+
 		#region IConnectionFactory Members
 
 		/// <summary>
@@ -162,33 +243,32 @@ namespace Apache.NMS.EMS
 			{
 				try
 				{
-					if(null == this.brokerUri || !this.brokerUri.Equals(value))
+					// Create or Re-create the TIBCO connection factory.
+					this.brokerUri = ParseUriProperties(value);
+					if(null == this.brokerUri)
 					{
-						// Re-create the TIBCO connection factory.
-						this.brokerUri = value;
-						if(null == this.brokerUri)
+						this.tibcoConnectionFactory = new TIBCO.EMS.ConnectionFactory();
+					}
+					else
+					{
+						if(null == this.clientId)
 						{
-							this.tibcoConnectionFactory = new TIBCO.EMS.ConnectionFactory();
+							this.tibcoConnectionFactory = new TIBCO.EMS.ConnectionFactory(TrimParens(this.brokerUri.AbsolutePath));
 						}
 						else
 						{
-							if(null == this.clientId)
+							if(null == this.properties)
 							{
-								this.tibcoConnectionFactory = new TIBCO.EMS.ConnectionFactory(this.brokerUri.OriginalString);
+								this.tibcoConnectionFactory = new TIBCO.EMS.ConnectionFactory(TrimParens(this.brokerUri.AbsolutePath),
this.clientId);
 							}
 							else
 							{
-								if(null == this.properties)
-								{
-									this.tibcoConnectionFactory = new TIBCO.EMS.ConnectionFactory(this.brokerUri.OriginalString,
this.clientId);
-								}
-								else
-								{
-									this.tibcoConnectionFactory = new TIBCO.EMS.ConnectionFactory(this.brokerUri.OriginalString,
this.clientId, this.properties);
-								}
+								this.tibcoConnectionFactory = new TIBCO.EMS.ConnectionFactory(TrimParens(this.brokerUri.AbsolutePath),
this.clientId, this.properties);
 							}
 						}
 					}
+
+					ConfigureConnectionFactory();
 				}
 				catch(Exception ex)
 				{
@@ -197,6 +277,37 @@ namespace Apache.NMS.EMS
 			}
 		}
 
+		private Uri ParseUriProperties(Uri rawUri)
+		{
+			Tracer.InfoFormat("BrokerUri set = {0}", rawUri.OriginalString);
+			Uri parsedUri = rawUri;
+
+			if(!String.IsNullOrEmpty(rawUri.Query) && !rawUri.OriginalString.EndsWith(")"))
+			{
+				parsedUri = new Uri(rawUri.OriginalString);
+				// Since the Uri class will return the end of a Query string found in a Composite
+				// URI we must ensure that we trim that off before we proceed.
+				string query = parsedUri.Query.Substring(parsedUri.Query.LastIndexOf(")") + 1);
+
+				StringDictionary properties = URISupport.ParseQuery(query);
+
+				StringDictionary connection = URISupport.ExtractProperties(properties, "connection.");
+				StringDictionary nms = URISupport.ExtractProperties(properties, "nms.");
+
+				IntrospectionSupport.SetProperties(this, connection, "connection.");
+				IntrospectionSupport.SetProperties(this, nms, "nms.");
+
+				parsedUri = URISupport.CreateRemainingUri(parsedUri, properties);
+			}
+
+			return parsedUri;
+		}
+
+		private string TrimParens(string stringWithParens)
+		{
+			return stringWithParens.TrimStart('(').TrimEnd(')');
+		}
+
 		/// <summary>
 		/// Get/or set the redelivery policy that new IConnection objects are
 		/// assigned upon creation.

Modified: activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x/vs2008-ems.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x/vs2008-ems.csproj?rev=1705384&r1=1705383&r2=1705384&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x/vs2008-ems.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x/vs2008-ems.csproj Fri Sep 25 23:20:28
2015
@@ -74,6 +74,7 @@
     <Compile Include="src\main\csharp\ConnectionFactory.cs" />
     <Compile Include="src\main\csharp\ConnectionMetaData.cs" />
     <Compile Include="src\main\csharp\ExceptionUtil.cs" />
+    <Compile Include="src\main\csharp\IntrospectionSupport.cs" />
     <Compile Include="src\main\csharp\StreamMessage.cs" />
     <Compile Include="src\main\csharp\QueueBrowser.cs" />
     <Compile Include="src\main\csharp\Destination.cs" />

Propchange: activemq/activemq-dotnet/Apache.NMS.EMS/branches/1.7.x/vs2008-ems.csproj
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 25 23:20:28 2015
@@ -0,0 +1 @@
+/activemq/activemq-dotnet/Apache.NMS.EMS/trunk/vs2008-ems.csproj:1705382



Mime
View raw message