You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ha...@apache.org on 2025/04/14 08:32:52 UTC

(activemq-nms-amqp) 01/04: AMQNET-817 - Ability to configure hostname

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 02349e8ec4b30d4d61c68cbfe10711804ca4ab87
Author: Andreas Ländle <96...@users.noreply.github.com>
AuthorDate: Thu Apr 3 06:59:30 2025 +0000

    AMQNET-817 - Ability to configure hostname
---
 docs/configuration.md                        | 1 +
 src/NMS.AMQP/Meta/NmsConnectionInfo.cs       | 1 +
 src/NMS.AMQP/NmsConnectionFactory.cs         | 8 ++++++++
 src/NMS.AMQP/Provider/Amqp/AmqpConnection.cs | 2 +-
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/docs/configuration.md b/docs/configuration.md
index c414126..4500d3b 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -18,6 +18,7 @@ The options apply to the behavior of the NMS objects such as Connection, Session
 - **nms.username** User name value used to authenticate the connection.
 - **nms.password** The password value used to authenticate the connection.
 - **nms.clientId** The ClientId value that is applied to the connection.
+- **nms.hostname** 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.
 - **nms.localMessageExpiry** Controls whether MessageConsumer instances will locally filter expired Messages or deliver them. By default this value is set to true and expired messages will be filtered.
 - **nms.sendTimeout** Timeout value that controls how long the client waits on completion of a synchronous message send before returning an error. By default the client will wait indefinitely for a send to complete.
 - **nms.requestTimeout** Timeout value that controls how long the client waits on completion of various synchronous interactions, such as opening a producer or consumer, before returning an error. Does not affect synchronous message sends. By default the client will wait indefinitely for a request to complete.
diff --git a/src/NMS.AMQP/Meta/NmsConnectionInfo.cs b/src/NMS.AMQP/Meta/NmsConnectionInfo.cs
index f9120c6..dc56d3c 100644
--- a/src/NMS.AMQP/Meta/NmsConnectionInfo.cs
+++ b/src/NMS.AMQP/Meta/NmsConnectionInfo.cs
@@ -60,6 +60,7 @@ namespace Apache.NMS.AMQP.Meta
         public NmsConnectionId Id { get; }
         public bool IsExplicitClientId { get; private set; }
         public string ClientId { get; private set; }
+        public string HostName { 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 7684f30..bd4935f 100644
--- a/src/NMS.AMQP/NmsConnectionFactory.cs
+++ b/src/NMS.AMQP/NmsConnectionFactory.cs
@@ -168,6 +168,13 @@ namespace Apache.NMS.AMQP
         /// </summary>
         public string ClientId { get; set; }
 
+        /// <summary>
+        /// Sets and gets 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.
+        /// </summary>
+        public string HostName { get; set; }
+
         /// <summary>
         /// Sets and gets the prefetch values for consumers
         /// </summary>
@@ -340,6 +347,7 @@ namespace Apache.NMS.AMQP
             {
                 UserName = userName,
                 Password = password,
+                HostName = HostName,
                 ConfiguredUri = BrokerUri,
                 RequestTimeout = RequestTimeout,
                 SendTimeout = SendTimeout,
diff --git a/src/NMS.AMQP/Provider/Amqp/AmqpConnection.cs b/src/NMS.AMQP/Provider/Amqp/AmqpConnection.cs
index 8644c8e..107c31d 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 = remoteUri.Host;
+            open.HostName = String.IsNullOrEmpty(Info.HostName) ? remoteUri.Host : Info.HostName;
             open.IdleTimeOut = (uint) Info.IdleTimeOut;
             open.DesiredCapabilities = new[]
             {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@activemq.apache.org
For additional commands, e-mail: commits-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact