Skip to content
Permalink
Browse files
https://issues.apache.org/activemq/browse/AMQNET-261
Updates to the Uri Parsing and Composite Uri handling.  Allows most of the various forms of URIs that the AMQ docs call out.  

Added several new unit tests for URISupport and Tests in NMS.ActiveMQ to ensure that the Connection params are getting set even when a composite Uri is used for Failover transport.
  • Loading branch information
Timothy A. Bish committed Jul 15, 2010
1 parent 4f9ebdc commit f7ad90c156ac7db8485c1a70989c6b3c7ce579e7
Showing 5 changed files with 37 additions and 27 deletions.
@@ -337,7 +337,7 @@ public ISession CreateSession(AcknowledgementMode sessionAcknowledgementMode)
Session session = new Session(this, info, sessionAcknowledgementMode, this.dispatchAsync);

// Set properties on session using parameters prefixed with "session."
URISupport.CompositeData c = URISupport.parseComposite(this.brokerUri);
URISupport.CompositeData c = URISupport.ParseComposite(this.brokerUri);
URISupport.SetProperties(session, c.Parameters, "session.");

if(IsStarted)
@@ -16,6 +16,7 @@
*/

using System;
using System.Collections.Specialized;
using Apache.NMS.Stomp.Util;
using Apache.NMS.Stomp.Commands;
using Apache.NMS.Stomp.Transport;
@@ -77,7 +78,7 @@ public ConnectionFactory(string brokerUri)
}

public ConnectionFactory(string brokerUri, string clientID)
: this(new Uri(brokerUri), clientID)
: this(URISupport.CreateCompatibleUri(brokerUri), clientID)
{
}

@@ -103,14 +104,11 @@ public IConnection CreateConnection(string userName, string password)

try
{
// Strip off the activemq prefix, if it exists.
Uri uri = new Uri(URISupport.stripPrefix(brokerUri.OriginalString, "stomp:"));
Tracer.InfoFormat("Connecting to: {0}", brokerUri.ToString());

Tracer.InfoFormat("Connecting to: {0}", uri.ToString());
ITransport transport = TransportFactory.CreateTransport(brokerUri);

ITransport transport = TransportFactory.CreateTransport(uri);

connection = new Connection(uri, transport, this.ClientIdGenerator);
connection = new Connection(brokerUri, transport, this.ClientIdGenerator);

connection.UserName = userName;
connection.Password = password;
@@ -162,17 +160,30 @@ public Uri BrokerUri
get { return brokerUri; }
set
{
brokerUri = value;
brokerUri = new Uri(URISupport.StripPrefix(value.OriginalString, "stomp:"));

Uri uri = new Uri(URISupport.stripPrefix(brokerUri.OriginalString, "stomp:"));
if(brokerUri.Query != null)
{
StringDictionary properties = URISupport.ParseQuery(brokerUri.Query);

StringDictionary connection = URISupport.ExtractProperties(properties, "connection.");
StringDictionary nms = URISupport.ExtractProperties(properties, "nms.");

if(connection != null)
{
URISupport.SetProperties(this, connection, "connection.");
}

if(nms != null)
{
URISupport.SetProperties(this.PrefetchPolicy, nms, "nms.PrefetchPolicy.");
URISupport.SetProperties(this.RedeliveryPolicy, nms, "nms.RedeliveryPolicy.");
}

URISupport.CompositeData c = URISupport.parseComposite(uri);
URISupport.SetProperties(this, c.Parameters, "connection.");
URISupport.SetProperties(this.PrefetchPolicy, c.Parameters, "nms.PrefetchPolicy.");
URISupport.SetProperties(this.RedeliveryPolicy, c.Parameters, "nms.RedeliveryPolicy.");
brokerUri = URISupport.CreateRemainingUri(brokerUri, properties);
}
}
}

public string UserName
{
get { return connectionUserName; }
@@ -25,15 +25,15 @@ public class FailoverTransportFactory : ITransportFactory
{
private ITransport doConnect(Uri location)
{
ITransport transport = CreateTransport(URISupport.parseComposite(location));
ITransport transport = CreateTransport(URISupport.ParseComposite(location));
transport = new MutexTransport(transport);
transport = new ResponseCorrelator(transport);
return transport;
}

public ITransport CompositeConnect(Uri location)
{
return CreateTransport(URISupport.parseComposite(location));
return CreateTransport(URISupport.ParseComposite(location));
}

public ITransport CompositeConnect(Uri location, SetTransport setTransport)
@@ -57,21 +57,20 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\NUnit\net-2.0\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="nunit.framework.extensions, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\NUnit\net-2.0\nunit.framework.extensions.dll</HintPath>
<Package>mono-nunit</Package>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="Apache.NMS, Version=1.4.0.2007, Culture=neutral, PublicKeyToken=82756feee3957618">
<Reference Include="Apache.NMS, Version=1.4.0.2013, Culture=neutral, PublicKeyToken=82756feee3957618">
<SpecificVersion>False</SpecificVersion>
<HintPath>build\mono-2.0\debug\Apache.NMS.dll</HintPath>
</Reference>
<Reference Include="Apache.NMS.Stomp, Version=1.4.0.2010, Culture=neutral, PublicKeyToken=82756feee3957618">
<Reference Include="Apache.NMS.Stomp, Version=1.4.0.2015, Culture=neutral, PublicKeyToken=82756feee3957618">
<SpecificVersion>False</SpecificVersion>
<HintPath>build\mono-2.0\debug\Apache.NMS.Stomp.dll</HintPath>
</Reference>
<Reference Include="nunit.framework.extensions, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\NUnit\mono-2.0\nunit.framework.extensions.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -55,9 +55,9 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="Apache.NMS, Version=1.4.0.2007, Culture=neutral, PublicKeyToken=82756feee3957618">
<Reference Include="Apache.NMS, Version=1.4.0.2021, Culture=neutral, PublicKeyToken=82756feee3957618">
<SpecificVersion>False</SpecificVersion>
<HintPath>build\mono-2.0\debug\Apache.NMS.dll</HintPath>
<HintPath>lib\Apache.NMS\mono-2.0\Apache.NMS.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>

0 comments on commit f7ad90c

Please sign in to comment.