Configuration 代码中的NServiceBus主节点配置以正确解析Dns

Configuration 代码中的NServiceBus主节点配置以正确解析Dns,configuration,nservicebus,Configuration,Nservicebus,前几天,我在尝试使用计算机名而不是ip进行部署时遇到了此错误: Could not translate format name to independent name: XXXX 经过一些研究,我发现Udi有这样的描述: 问题是我们无法关闭MSMQ广告 因此,我已经解决了这个问题,将机器名解析为ipv4地址: public class MasterNodeConfiguration : IProvideConfiguration<MasterNodeConfig> { pr

前几天,我在尝试使用计算机名而不是ip进行部署时遇到了此错误:

Could not translate format name to independent name: XXXX
经过一些研究,我发现Udi有这样的描述:

问题是我们无法关闭MSMQ广告

因此,我已经解决了这个问题,将机器名解析为ipv4地址:

public class MasterNodeConfiguration : IProvideConfiguration<MasterNodeConfig>
{
    private const string _masterNodeMachineNameKey = "MasterNodeMachineName";
    private string _masterNodeMachineName = string.Empty;

    public MasterNodeConfiguration(IApplicationSettingsReader applicationSettingsReader)
    {
        var machineName = applicationSettingsReader.GetValue(_masterNodeMachineNameKey);

        ResolveMachineNameToIpAddress(machineName);
    }

    private void ResolveMachineNameToIpAddress(string machineName)
    {
        if (string.IsNullOrEmpty(machineName) == false)
        {
            _masterNodeMachineName = Dns.GetHostAddresses(machineName)
                .Single(address => address.AddressFamily == AddressFamily.InterNetwork)
                .ToString();
        }
    }

    public MasterNodeConfig GetConfiguration()
    {
        return new MasterNodeConfig
        {
            Node = _masterNodeMachineName,
        };
    }
}
我已经跨机器边界对此进行了测试,并且效果良好

我的问题:

此配置与我们的worker/dist/sender/publisher/subscriber配置位于同一程序集中。它们都是使用以下代码编写的:NServiceBus.Configure.With.DefineEndpointName…,这意味着如果这些配置不包括上述appsettings键,则所有这些配置将拾取节点值为NULL的主节点配置。这是危险的还是NSB会像没有指定MasterConfig那样简单地处理空节点