Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 74800 invoked from network); 25 Aug 2009 22:27:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Aug 2009 22:27:35 -0000 Received: (qmail 24959 invoked by uid 500); 25 Aug 2009 22:28:00 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 24902 invoked by uid 500); 25 Aug 2009 22:28:00 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 24893 invoked by uid 99); 25 Aug 2009 22:28:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Aug 2009 22:28:00 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Aug 2009 22:27:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 807D023888E4; Tue, 25 Aug 2009 22:27:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r807840 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport: ./ Discovery/ Failover/ Mock/ Tcp/ Date: Tue, 25 Aug 2009 22:27:30 -0000 To: commits@activemq.apache.org From: jgomes@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090825222730.807D023888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jgomes Date: Tue Aug 25 22:27:29 2009 New Revision: 807840 URL: http://svn.apache.org/viewvc?rev=807840&view=rev Log: Applied patch from Mark Gellings. Hope I merged everything correctly. Thanks, Mark! Fixes [AMQNET-159]. (See https://issues.apache.org/activemq/browse/AMQNET-159) Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Discovery/DiscoveryTransportFactory.cs activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransportFactory.cs activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ITransportFactory.cs activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransportFactory.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/TransportFactory.cs Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Discovery/DiscoveryTransportFactory.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Discovery/DiscoveryTransportFactory.cs?rev=807840&r1=807839&r2=807840&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Discovery/DiscoveryTransportFactory.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Discovery/DiscoveryTransportFactory.cs Tue Aug 25 22:27:29 2009 @@ -40,7 +40,7 @@ agent.OnNewServiceFound += agent_OnNewServiceFound; agent.OnServiceRemoved += agent_OnServiceRemoved; } - + public DiscoveryTransportFactory() { lock(uriLock) @@ -48,7 +48,7 @@ currentServiceName = String.Empty; } } - + public static Uri DiscoveredUri { get { lock(uriLock) { return discoveredUri; } } @@ -92,7 +92,7 @@ } Uri hostUri = DiscoveredUri; - + if(null == hostUri) { // If a new broker is found the agent will fire an event which will result in discoveredUri being set. @@ -113,6 +113,12 @@ throw new NMSConnectionException("Composite connection not supported with MulticastDiscovery transport."); } + + public ITransport CompositeConnect(Uri location, SetTransport setTransport) + { + throw new NMSConnectionException("Composite connection not supported with Discovery transport."); + } + #endregion } } Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs?rev=807840&r1=807839&r2=807840&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs Tue Aug 25 22:27:29 2009 @@ -79,6 +79,25 @@ private bool _trackMessages = false; private int _maxCacheSize = 256; private TimeSpan requestTimeout = NMSConstants.defaultRequestTimeout; + private volatile Exception _failure; + private readonly object _syncLock = new object(); + + internal Exception Failure + { + get + { + return _failure; + } + + set + { + lock(_syncLock) + { + _failure = value; + } + + } + } public TimeSpan RequestTimeout { @@ -258,10 +277,10 @@ reconnectMutex.ReleaseMutex(); } - if( this.Interrupted != null ) - { - this.Interrupted( transport ); - } + if(this.Interrupted != null) + { + this.Interrupted(transport); + } } } @@ -714,7 +733,7 @@ cc.FaultTolerant = true; t.Oneway(cc); stateTracker.DoRestore(t); - + Tracer.Info("Sending queued commands..."); Dictionary tmpMap = null; lock(((ICollection) requestMap).SyncRoot) @@ -751,28 +770,55 @@ } } - public Object Narrow(Type type) - { - if(this.GetType().Equals(type)) - { - return this; - } - else if(ConnectedTransport != null) - { - return ConnectedTransport.Narrow(type); - } + public Object Narrow(Type type) + { + if(this.GetType().Equals(type)) + { + return this; + } + else if(ConnectedTransport != null) + { + return ConnectedTransport.Narrow(type); + } - return null; - } + return null; + } public bool IsFaultTolerant { get { return true; } } + private bool _asyncConnect = false; + + /// + /// Gets or sets a value indicating whether to asynchronously connect to sockets + /// + /// true if [async connect]; otherwise, false. + public bool AsyncConnect + { + set + { + _asyncConnect = value; + } + } + + private int _asyncTimeout = 45000; + + /// + /// If doing an asynchronous connect, the milliseconds before timing out if no connection can be made + /// + /// The async timeout. + public int AsyncTimeout + { + set + { + _asyncTimeout = value; + } + } + private bool doConnect() { - Exception failure = null; try { reconnectMutex.WaitOne(); @@ -786,7 +832,7 @@ List connectList = ConnectList; if(connectList.Count == 0) { - failure = new NMSConnectionException("No URIs available for connection."); + Failure = new NMSConnectionException("No URIs available for connection."); } else { @@ -794,6 +840,7 @@ { ReconnectDelay = InitialReconnectDelay; } + try { backupMutex.WaitOne(); @@ -817,11 +864,11 @@ ConnectedTransport = t; connectFailures = 0; connected = true; - if( this.Resumed != null ) - { - this.Resumed( t ); - } - Tracer.InfoFormat("Successfully reconnected to backup {0}", uri.ToString()); + if(this.Resumed != null) + { + this.Resumed(t); + } + Tracer.InfoFormat("Successfully reconnected to backup {0}", uri.ToString()); return false; } catch(Exception e) @@ -836,65 +883,128 @@ backupMutex.ReleaseMutex(); } - foreach(Uri uri in connectList) + ManualResetEvent allDone = new ManualResetEvent(false); + ITransport transport = null; + Uri chosenUri = null; + object syncLock = new object(); + + try { - if(ConnectedTransport != null || disposed) + foreach(Uri uri in connectList) { - break; + if(ConnectedTransport != null || disposed) + { + break; + } + + Tracer.DebugFormat("Attempting connect to: {0}", uri); + + if(_asyncConnect) + { + // set connector up + Connector connector = new Connector( + delegate(ITransport transportToUse, Uri uriToUse) { + if(transport == null) + { + lock(syncLock) + { + if(transport == null) + { + //the transport has not yet been set asynchronously so set it + transport = transportToUse; + chosenUri = uriToUse; + } + //notify issuing thread to move on + allDone.Set(); + } + } + }, uri, this); + + // initiate a thread to try connecting to broker + Thread thread = new Thread(connector.DoConnect); + thread.Name = uri.ToString(); + thread.Start(); + } + else + { + // synchronous connect + try + { + Tracer.DebugFormat("Attempting connect to: {0}", uri.ToString()); + transport = TransportFactory.CompositeConnect(uri); + chosenUri = uri; + break; + } + catch(Exception e) + { + Failure = e; + Tracer.DebugFormat("Connect fail to: {0}, reason: {1}", uri, e.Message); + } + } } - try + if(_asyncConnect) { - Tracer.DebugFormat("Attempting connect to: {0}", uri.ToString()); - ITransport t = TransportFactory.CompositeConnect(uri); - t.Command = new CommandHandler(onCommand); - t.Exception = new ExceptionHandler(onException); - t.Start(); + // now wait for transport to be populated, but timeout eventually + allDone.WaitOne(_asyncTimeout, false); + } + + if(transport != null) + { + transport.Command = new CommandHandler(onCommand); + transport.Exception = new ExceptionHandler(onException); + transport.Start(); if(started) { - restoreTransport(t); + restoreTransport(transport); + } + + if(this.Resumed != null) + { + this.Resumed(transport); } - if( this.Resumed != null ) - { - this.Resumed( t ); - } - Tracer.Debug("Connection established"); ReconnectDelay = InitialReconnectDelay; - ConnectedTransportURI = uri; - ConnectedTransport = t; + ConnectedTransportURI = chosenUri; + ConnectedTransport = transport; connectFailures = 0; connected = true; if(firstConnection) { firstConnection = false; - Tracer.InfoFormat("Successfully connected to: {0}", uri.ToString()); + Tracer.InfoFormat("Successfully connected to: {0}", chosenUri.ToString()); } else { - Tracer.InfoFormat("Successfully reconnected to: {0}", uri.ToString()); + Tracer.InfoFormat("Successfully reconnected to: {0}", chosenUri.ToString()); } return false; } - catch(Exception e) + + if(_asyncConnect) { - failure = e; - Tracer.ErrorFormat("Connect fail to '{0}': {1}", uri.ToString(), e.Message); + Tracer.DebugFormat("Connect failed after waiting for asynchronous callback."); } + + } + catch(Exception e) + { + Failure = e; + Tracer.DebugFormat("Connect attempt failed. Reason: {1}", e.Message); } } - } - if(MaxReconnectAttempts > 0 && ++connectFailures >= MaxReconnectAttempts) - { - Tracer.ErrorFormat("Failed to connect to transport after {0} attempt(s)", connectFailures); - connectionFailure = failure; - this.Exception(this, connectionFailure); - return false; + if(MaxReconnectAttempts > 0 && ++connectFailures >= MaxReconnectAttempts) + { + Tracer.ErrorFormat("Failed to connect to transport after {0} attempt(s)", connectFailures); + connectionFailure = Failure; + this.Exception(this, connectionFailure); + return false; + } } } finally @@ -934,6 +1044,57 @@ return !disposed; } + /// + /// This class is a helper for the asynchronous connect option + /// + public class Connector + { + /// + /// callback to properly set chosen transport + /// + SetTransport _setTransport; + + /// + /// Uri to try connecting to + /// + Uri _uri; + + /// + /// Failover transport issuing the connection attempt + /// + private FailoverTransport _transport; + + /// + /// Initializes a new instance of the class. + /// + /// The set transport. + /// The URI. + /// The transport. + public Connector(SetTransport setTransport, Uri uri, FailoverTransport transport) + { + _uri = uri; + _setTransport = setTransport; + _transport = transport; + } + + /// + /// Does the connect. + /// + public void DoConnect() + { + try + { + TransportFactory.AsyncCompositeConnect(_uri, _setTransport); + } + catch(Exception e) + { + _transport.Failure = e; + Tracer.DebugFormat("Connect fail to: {0}, reason: {1}", _uri, e.Message); + } + + } + } + private bool buildBackups() { try @@ -989,6 +1150,7 @@ return false; } + public bool IsDisposed { get { return disposed; } @@ -1036,13 +1198,13 @@ get { return interruptedHandler; } set { this.interruptedHandler = value; } } - + public ResumedHandler Resumed { get { return resumedHandler; } set { this.resumedHandler = value; } } - + public bool IsStarted { get { return started; } Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransportFactory.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransportFactory.cs?rev=807840&r1=807839&r2=807840&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransportFactory.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransportFactory.cs Tue Aug 25 22:27:29 2009 @@ -36,6 +36,11 @@ return CreateTransport(URISupport.parseComposite(location)); } + public ITransport CompositeConnect(Uri location, SetTransport setTransport) + { + throw new NMSConnectionException("Asynchronous composite connection not supported with Failover transport."); + } + public ITransport CreateTransport(Uri location) { return doConnect(location); Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ITransportFactory.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ITransportFactory.cs?rev=807840&r1=807839&r2=807840&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ITransportFactory.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ITransportFactory.cs Tue Aug 25 22:27:29 2009 @@ -19,9 +19,12 @@ namespace Apache.NMS.ActiveMQ.Transport { + public delegate void SetTransport(ITransport transport, Uri uri); + public interface ITransportFactory { ITransport CreateTransport(Uri location); ITransport CompositeConnect(Uri location); + ITransport CompositeConnect(Uri location, SetTransport setTransport); } } Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransportFactory.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransportFactory.cs?rev=807840&r1=807839&r2=807840&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransportFactory.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransportFactory.cs Tue Aug 25 22:27:29 2009 @@ -16,11 +16,8 @@ */ using System; -using System.Collections.Generic; using System.Collections.Specialized; using Apache.NMS.Util; -using Apache.NMS.ActiveMQ.Commands; -using Apache.NMS.ActiveMQ.Transport; namespace Apache.NMS.ActiveMQ.Transport.Mock { @@ -28,72 +25,72 @@ /// Factory class to create the MockTransport when given on a URI as mock://XXX /// public class MockTransportFactory : ITransportFactory - { + { public MockTransportFactory() { } - #region Properties - - private TimeSpan requestTimeout = NMSConstants.defaultRequestTimeout; - public int RequestTimeout - { - get { return (int) requestTimeout.TotalMilliseconds; } - set { requestTimeout = TimeSpan.FromMilliseconds(value); } - } - - private bool useLogging = false; - public bool UseLogging - { - get { return useLogging; } - set { useLogging = value; } - } - - private string wireFormat = "OpenWire"; - public string WireFormat - { - get { return wireFormat; } - set { wireFormat = value; } - } - - private bool failOnReceiveMessage = false; - public bool FailOnReceiveMessage - { - get { return failOnReceiveMessage; } - set { failOnReceiveMessage = value; } - } - - private int numReceivedMessagesBeforeFail = 0; - public int NumReceivedMessagesBeforeFail - { - get { return numReceivedMessagesBeforeFail; } - set { numReceivedMessagesBeforeFail = value; } - } - - private bool failOnSendMessage = false; - public bool FailOnSendMessage - { - get{ return failOnSendMessage; } - set{ this.failOnSendMessage = value; } - } - - private int numSentMessagesBeforeFail = 0; - public int NumSentMessagesBeforeFail - { - get { return numSentMessagesBeforeFail ; } - set { numSentMessagesBeforeFail = value; } - } - - private bool failOnCreate = false; - public bool FailOnCreate - { - get{ return failOnCreate; } - set{ this.failOnCreate = value; } - } - - #endregion - - public ITransport CreateTransport(Uri location) + #region Properties + + private TimeSpan requestTimeout = NMSConstants.defaultRequestTimeout; + public int RequestTimeout + { + get { return (int) requestTimeout.TotalMilliseconds; } + set { requestTimeout = TimeSpan.FromMilliseconds(value); } + } + + private bool useLogging = false; + public bool UseLogging + { + get { return useLogging; } + set { useLogging = value; } + } + + private string wireFormat = "OpenWire"; + public string WireFormat + { + get { return wireFormat; } + set { wireFormat = value; } + } + + private bool failOnReceiveMessage = false; + public bool FailOnReceiveMessage + { + get { return failOnReceiveMessage; } + set { failOnReceiveMessage = value; } + } + + private int numReceivedMessagesBeforeFail = 0; + public int NumReceivedMessagesBeforeFail + { + get { return numReceivedMessagesBeforeFail; } + set { numReceivedMessagesBeforeFail = value; } + } + + private bool failOnSendMessage = false; + public bool FailOnSendMessage + { + get { return failOnSendMessage; } + set { this.failOnSendMessage = value; } + } + + private int numSentMessagesBeforeFail = 0; + public int NumSentMessagesBeforeFail + { + get { return numSentMessagesBeforeFail; } + set { numSentMessagesBeforeFail = value; } + } + + private bool failOnCreate = false; + public bool FailOnCreate + { + get { return failOnCreate; } + set { this.failOnCreate = value; } + } + + #endregion + + public ITransport CreateTransport(Uri location) { ITransport transport = CompositeConnect(location); @@ -101,40 +98,44 @@ transport = new ResponseCorrelator(transport); transport.RequestTimeout = this.requestTimeout; - return transport; + return transport; } - + public ITransport CompositeConnect(Uri location) { - Tracer.Debug("MockTransportFactory: Create new Transport with options: " + location.Query); - + Tracer.Debug("MockTransportFactory: Create new Transport with options: " + location.Query); + // Extract query parameters from broker Uri StringDictionary map = URISupport.ParseQuery(location.Query); - // Set transport. properties on this (the factory) - URISupport.SetProperties(this, map, "transport."); - - if(String.Compare(this.wireFormat, "stomp", true) != 0 && - String.Compare(this.wireFormat, "openwire", true) != 0) - { - throw new IOException("Unsupported WireFormat Supplied for MockTransport"); - } - - if(this.FailOnCreate == true) - { - throw new IOException("Failed to Create new MockTransport."); - } - - // Create the Mock Transport - MockTransport transport = new MockTransport(); - - transport.FailOnReceiveMessage = this.FailOnReceiveMessage; - transport.NumReceivedMessagesBeforeFail = this.NumReceivedMessagesBeforeFail; - transport.FailOnSendMessage = this.FailOnSendMessage; - transport.NumSentMessagesBeforeFail = this.NumSentMessagesBeforeFail; + // Set transport. properties on this (the factory) + URISupport.SetProperties(this, map, "transport."); - return transport; + if(String.Compare(this.wireFormat, "stomp", true) != 0 && + String.Compare(this.wireFormat, "openwire", true) != 0) + { + throw new IOException("Unsupported WireFormat Supplied for MockTransport"); + } + + if(this.FailOnCreate == true) + { + throw new IOException("Failed to Create new MockTransport."); + } + + // Create the Mock Transport + MockTransport transport = new MockTransport(); + + transport.FailOnReceiveMessage = this.FailOnReceiveMessage; + transport.NumReceivedMessagesBeforeFail = this.NumReceivedMessagesBeforeFail; + transport.FailOnSendMessage = this.FailOnSendMessage; + transport.NumSentMessagesBeforeFail = this.NumSentMessagesBeforeFail; + + return transport; + } + + public ITransport CompositeConnect(Uri location, SetTransport setTransport) + { + throw new NMSConnectionException("Asynchronous composite connection not supported with Mock transport."); } - } } 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=807840&r1=807839&r2=807840&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 Aug 25 22:27:29 2009 @@ -16,7 +16,6 @@ */ using System; -using System.Collections.Generic; using System.Collections.Specialized; using System.Net; using System.Net.Sockets; @@ -104,6 +103,11 @@ public ITransport CompositeConnect(Uri location) { + return CompositeConnect(location, null); + } + + public ITransport CompositeConnect(Uri location, SetTransport setTransport) + { // Extract query parameters from broker Uri StringDictionary map = URISupport.ParseQuery(location.Query); @@ -137,6 +141,11 @@ transport.RequestTimeout = this.requestTimeout; + if(setTransport != null) + { + setTransport(transport, location); + } + return transport; } @@ -160,6 +169,7 @@ // the new hostname IP. #if CACHE_HOSTENTRIES private static IDictionary CachedIPHostEntries = new Dictionary(); + private static readonly object _syncLock = new object(); #endif public static IPHostEntry GetIPHostEntry(string host) { @@ -168,16 +178,19 @@ #if CACHE_HOSTENTRIES string hostUpperName = host.ToUpper(); - if(!CachedIPHostEntries.TryGetValue(hostUpperName, out ipEntry)) + lock (_syncLock) { - try + if (!CachedIPHostEntries.TryGetValue(hostUpperName, out ipEntry)) { - ipEntry = Dns.GetHostEntry(hostUpperName); - CachedIPHostEntries.Add(hostUpperName, ipEntry); - } - catch - { - ipEntry = null; + try + { + ipEntry = Dns.GetHostEntry(hostUpperName); + CachedIPHostEntries.Add(hostUpperName, ipEntry); + } + catch + { + ipEntry = null; + } } } #else Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/TransportFactory.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/TransportFactory.cs?rev=807840&r1=807839&r2=807840&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/TransportFactory.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/TransportFactory.cs Tue Aug 25 22:27:29 2009 @@ -16,12 +16,10 @@ */ using System; -using System.Collections.Generic; - using Apache.NMS.ActiveMQ.Transport.Discovery; using Apache.NMS.ActiveMQ.Transport.Failover; -using Apache.NMS.ActiveMQ.Transport.Tcp; using Apache.NMS.ActiveMQ.Transport.Mock; +using Apache.NMS.ActiveMQ.Transport.Tcp; namespace Apache.NMS.ActiveMQ.Transport { @@ -54,6 +52,12 @@ return tf.CompositeConnect(location); } + public static ITransport AsyncCompositeConnect(Uri location, SetTransport setTransport) + { + ITransportFactory tf = TransportFactory.CreateTransportFactory(location); + return tf.CompositeConnect(location, setTransport); + } + /// /// Create a transport factory for the scheme. If we do not support the transport protocol, /// an NMSConnectionException will be thrown. @@ -75,20 +79,20 @@ { switch(scheme.ToLower()) { - case "tcp": - factory = new TcpTransportFactory(); - break; - case "discovery": - factory = new DiscoveryTransportFactory(); - break; - case "failover": - factory = new FailoverTransportFactory(); - break; - case "mock": - factory = new MockTransportFactory(); - break; - default: - throw new NMSConnectionException(String.Format("The transport {0} is not supported.", scheme)); + case "tcp": + factory = new TcpTransportFactory(); + break; + case "discovery": + factory = new DiscoveryTransportFactory(); + break; + case "failover": + factory = new FailoverTransportFactory(); + break; + case "mock": + factory = new MockTransportFactory(); + break; + default: + throw new NMSConnectionException(String.Format("The transport {0} is not supported.", scheme)); } } catch(NMSConnectionException)