1

前几天我在尝试使用机器名而不是 ip 进行部署时遇到了这个错误:

Could not translate format name to independent name: XXXX

经过一番研究,我发现了 Udi 的描述:http: //tech.groups.yahoo.com/group/nservicebus/message/15232

问题是我们无法关闭 MSMQ AD。

因此,我已经解决了这个问题,我将机器名称解析为 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 键,所有这些配置都将使用 Node 值为 NULL 的 MasterNode 配置。这是危险的还是 NSB 会像没有指定 MasterConfig 一样简单地处理 NULL 节点?

4

0 回答 0