Azure服务总线配对的命名空间-模拟故障转移 [英] Azure service bus paired namespace - simulate failover

查看:79
本文介绍了Azure服务总线配对的命名空间-模拟故障转移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用azure服务总线配对的命名空间,并且需要能够模拟故障转移到辅助命名空间.通过为主要名称空间输入错误的连接字符串,我确实可以正常工作,并且看到它进行了故障转移并将消息发送到次要名称空间.这似乎不再奏效.我找不到通过Azure管理门户或其他任何地方使名称空间脱机的方法.任何人都知道如何执行此操作吗?

I am working with azure service bus paired namespace and need to be able to simulate a failover to the secondary namespace. I did kind of have this working by entering an incorrect connection string for the primary namespace and saw it fail over and send the message to the secondary namespace. This no longer seems to do the trick. I can not find a way through the azure management portal or anywhere else to take a namespace offline. Anyone any ideas how to do this?

这是我的代码供参考

var pairedNamespaceConfiguration = this.pairedNamespaceConfigurationDictionary[configurationKey];
MessagingFactory factory = MessagingFactory.CreateFromConnectionString(pairedNamespaceConfiguration.PrimaryNamespace.ConnectionString);
MessagingFactory secondaryMessagingFactory = MessagingFactory.CreateFromConnectionString(pairedNamespaceConfiguration.SecondaryNamespace.ConnectionString);
NamespaceManager secondaryNamespaceManager = NamespaceManager.CreateFromConnectionString(pairedNamespaceConfiguration.SecondaryNamespace.ConnectionString);

SendAvailabilityPairedNamespaceOptions sendAvailabilityOptions = new SendAvailabilityPairedNamespaceOptions(secondaryNamespaceManager, secondaryMessagingFactory, pairedNamespaceConfiguration.BacklogQueueCount, TimeSpan.FromSeconds(pairedNamespaceConfiguration.FailoverIntervalSeconds), false);
factory.PairNamespaceAsync(sendAvailabilityOptions).Wait();
MessageSender messageSender = factory.CreateMessageSender(pairedNamespaceConfiguration.PathName);
string messageContent = JsonConvert.SerializeObject(message);

using(BrokeredMessage brokeredMessage = new BrokeredMessage(messageContent))
{
    messageSender.Send(brokeredMessage);
}

推荐答案

修改\ Windows \ system32 \ drivers \ etc \ hosts文件,以将原始命名空间指向类似于127.0.0.1的名称.这将使原始名称空间连接失败.

Modify your \Windows\system32\drivers\etc\hosts file to point the original namespace to something like 127.0.0.1. This will make the original namespace connection fail.

这篇关于Azure服务总线配对的命名空间-模拟故障转移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆