This is an automated email from the ASF dual-hosted git repository. havret pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/activemq-nms-amqp.git
commit 898d51035890559f1d1c94755f944defaf98ab2f Author: Andreas Ländle <[email protected]> AuthorDate: Tue Apr 8 07:46:18 2025 +0000 For sure `AMQP` related stuff should go to the related classes - so just moved code. --- docs/configuration.md | 2 +- src/NMS.AMQP/Meta/NmsConnectionInfo.cs | 1 - src/NMS.AMQP/NmsConnectionFactory.cs | 11 ----------- src/NMS.AMQP/Provider/Amqp/AmqpConnection.cs | 2 +- src/NMS.AMQP/Provider/Amqp/AmqpProvider.cs | 8 ++++++++ test/Apache-NMS-AMQP-Test/ConnectionFactoryTest.cs | 8 ++------ .../Provider/Amqp/AmqpProviderFactoryTest.cs | 8 ++++++-- 7 files changed, 18 insertions(+), 22 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index c4f8ab7..126b101 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -32,7 +32,7 @@ The options apply to the behavior of the NMS objects such as Connection, Session ### AMQP Configuration options -- **amqp.vhost** Optional, the name of the host to which we are connecting. By default this value is derived from the URI. Can be used to determine the correct service if connecting to an AMQP proxy. +- **amqp.vhost** Optional, the name of the virtual host to which we are connecting. By default this value is derived from the URI. Can be used to determine the correct service if connecting to an AMQP proxy. ### TCP Transport Configuration options When connected to a remote using plain TCP these options configure the behaviour of the underlying socket. These options are appended to the connection URI along with the other configuration options, for example: diff --git a/src/NMS.AMQP/Meta/NmsConnectionInfo.cs b/src/NMS.AMQP/Meta/NmsConnectionInfo.cs index d498058..f9120c6 100644 --- a/src/NMS.AMQP/Meta/NmsConnectionInfo.cs +++ b/src/NMS.AMQP/Meta/NmsConnectionInfo.cs @@ -60,7 +60,6 @@ namespace Apache.NMS.AMQP.Meta public NmsConnectionId Id { get; } public bool IsExplicitClientId { get; private set; } public string ClientId { get; private set; } - public string VHost { get; set; } public string UserName { get; set; } public string Password { get; set; } public Uri ConfiguredUri { get; set; } diff --git a/src/NMS.AMQP/NmsConnectionFactory.cs b/src/NMS.AMQP/NmsConnectionFactory.cs index c35044a..7684f30 100644 --- a/src/NMS.AMQP/NmsConnectionFactory.cs +++ b/src/NMS.AMQP/NmsConnectionFactory.cs @@ -168,13 +168,6 @@ namespace Apache.NMS.AMQP /// </summary> public string ClientId { get; set; } - /// <summary> - /// Sets and gets the name of the virtual host to which we are connecting. - /// By default this value is derived from the URI. - /// Can be used to determine the correct service if connecting to an AMQP proxy. - /// </summary> - public string VHost { get; set; } - /// <summary> /// Sets and gets the prefetch values for consumers /// </summary> @@ -347,7 +340,6 @@ namespace Apache.NMS.AMQP { UserName = userName, Password = password, - VHost = VHost, ConfiguredUri = BrokerUri, RequestTimeout = RequestTimeout, SendTimeout = SendTimeout, @@ -375,9 +367,6 @@ namespace Apache.NMS.AMQP { StringDictionary nmsOptions = PropertyUtil.FilterProperties(options, "nms."); PropertyUtil.SetProperties(this, nmsOptions); - - StringDictionary amqpOptions = PropertyUtil.FilterProperties(options, "amqp."); - PropertyUtil.SetProperties(this, amqpOptions); // TODO: Check if there are any unused options, if so throw argument exception } diff --git a/src/NMS.AMQP/Provider/Amqp/AmqpConnection.cs b/src/NMS.AMQP/Provider/Amqp/AmqpConnection.cs index bbb333d..6ca101c 100644 --- a/src/NMS.AMQP/Provider/Amqp/AmqpConnection.cs +++ b/src/NMS.AMQP/Provider/Amqp/AmqpConnection.cs @@ -114,7 +114,7 @@ namespace Apache.NMS.AMQP.Provider.Amqp open.ContainerId = Info.ClientId; open.ChannelMax = Info.ChannelMax; open.MaxFrameSize = (uint) Info.MaxFrameSize; - open.HostName = String.IsNullOrEmpty(Info.VHost) ? remoteUri.Host : Info.VHost; + open.HostName = String.IsNullOrEmpty(this.Provider.VHost) ? remoteUri.Host : this.Provider.VHost; open.IdleTimeOut = (uint) Info.IdleTimeOut; open.DesiredCapabilities = new[] { diff --git a/src/NMS.AMQP/Provider/Amqp/AmqpProvider.cs b/src/NMS.AMQP/Provider/Amqp/AmqpProvider.cs index 0720820..bff0b27 100644 --- a/src/NMS.AMQP/Provider/Amqp/AmqpProvider.cs +++ b/src/NMS.AMQP/Provider/Amqp/AmqpProvider.cs @@ -33,6 +33,14 @@ namespace Apache.NMS.AMQP.Provider.Amqp private readonly ITransportContext transport; private NmsConnectionInfo connectionInfo; private AmqpConnection connection; + + /// <summary> + /// Sets and gets the name of the virtual host to which we are connecting. + /// By default this value is derived from the URI. + /// Can be used to determine the correct service if connecting to an AMQP proxy. + /// </summary> + public string VHost { get; set; } + public AmqpProvider(Uri remoteUri, ITransportContext transport) { RemoteUri = remoteUri; diff --git a/test/Apache-NMS-AMQP-Test/ConnectionFactoryTest.cs b/test/Apache-NMS-AMQP-Test/ConnectionFactoryTest.cs index 0b2b361..6c62465 100644 --- a/test/Apache-NMS-AMQP-Test/ConnectionFactoryTest.cs +++ b/test/Apache-NMS-AMQP-Test/ConnectionFactoryTest.cs @@ -93,8 +93,7 @@ namespace NMS.AMQP.Test "&nms.requestTimeout=1000" + "&nms.sendTimeout=1000" + "&nms.localMessageExpiry=false" + - "&nms.maxNewConnectionRatePerSec=4" + - "&amqp.vhost=test-vhost"; + "&nms.maxNewConnectionRatePerSec=4"; NmsConnectionFactory factory = new NmsConnectionFactory(configuredUri); @@ -106,7 +105,6 @@ namespace NMS.AMQP.Test Assert.AreEqual(1000, factory.RequestTimeout); Assert.AreEqual(1000, factory.SendTimeout); Assert.AreEqual(4, factory.MaxNewConnectionRatePerSec); - Assert.AreEqual("test-vhost", factory.VHost); Assert.IsFalse(factory.LocalMessageExpiry); } @@ -124,8 +122,7 @@ namespace NMS.AMQP.Test "&nms.sendTimeout=1000" + "&nms.closeTimeout=2000" + "&nms.localMessageExpiry=false" + - "&nms.prefetchPolicy.all=55" + - "&amqp.vhost=test-vhost"; + "&nms.prefetchPolicy.all=55"; NmsConnectionFactory factory = new NmsConnectionFactory(new Uri(configuredUri)); @@ -141,7 +138,6 @@ namespace NMS.AMQP.Test Assert.AreEqual(55, factory.PrefetchPolicy.TopicPrefetch); Assert.AreEqual(55, factory.PrefetchPolicy.DurableTopicPrefetch); Assert.AreEqual(55, factory.PrefetchPolicy.QueueBrowserPrefetch); - Assert.AreEqual("test-vhost", factory.VHost); Assert.IsFalse(factory.LocalMessageExpiry); } diff --git a/test/Apache-NMS-AMQP-Test/Provider/Amqp/AmqpProviderFactoryTest.cs b/test/Apache-NMS-AMQP-Test/Provider/Amqp/AmqpProviderFactoryTest.cs index ea0de01..9b09240 100644 --- a/test/Apache-NMS-AMQP-Test/Provider/Amqp/AmqpProviderFactoryTest.cs +++ b/test/Apache-NMS-AMQP-Test/Provider/Amqp/AmqpProviderFactoryTest.cs @@ -26,7 +26,9 @@ namespace NMS.AMQP.Test.Provider.Amqp [TestFixture] public class AmqpProviderFactoryTest { - private uint customMaxHandle = 2048; + private const uint customMaxHandle = 2048; + + private const string customVHost = "test-vhost"; [Test] public void TestCreateAmqpProvider() @@ -50,13 +52,15 @@ namespace NMS.AMQP.Test.Provider.Amqp { Uri uri = new Uri("amqp://localhost:5672" + "?amqp.maxHandle=" + customMaxHandle + - "&amqp.traceFrames=true"); + "&amqp.traceFrames=true" + + "&amqp.vhost=" + customVHost); AmqpProvider provider = ProviderFactory.Create(uri) as AmqpProvider; Assert.IsNotNull(provider); Assert.AreEqual(customMaxHandle, provider.MaxHandle); Assert.IsTrue(provider.TraceFrames); + Assert.AreEqual(customVHost, provider.VHost); } [TearDown] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information, visit: https://activemq.apache.org/contact
