服务总线 - 如果第一个主机关闭,则无法发送

时间:2015-04-23 11:21:54

标签: c# servicebus

我们尝试连接服务总线主机的服务器场。

        serviceCustomConnection.Endpoints.Add(new Uri("sb://a.local/ServiceBusDefaultNamespace"));
        serviceCustomConnection.Endpoints.Add(new Uri("sb://b.local/ServiceBusDefaultNamespace"));
        serviceCustomConnection.Endpoints.Add(new Uri("sb://c.local/ServiceBusDefaultNamespace"));



        serviceCustomConnection.StsEndpoints.Add(new Uri("https://a.local:9355/ServiceBusDefaultNamespace"));
        serviceCustomConnection.StsEndpoints.Add(new Uri("https://b.local:9355/ServiceBusDefaultNamespace"));
        serviceCustomConnection.StsEndpoints.Add(new Uri("https://c.local:9355/ServiceBusDefaultNamespace"));

        serviceCustomConnection.RuntimePort = 9354;
        serviceCustomConnection.ManagementPort = 9355;

        ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.AutoDetect;

        _factory = MessagingFactory.CreateFromConnectionString(serviceCustomConnection.ToString());
        Console.WriteLine("Factory Created");
        retryPolicy = new RetryPolicy<ServiceBusTransientErrorDetectionStrategy>(new FixedInterval(10, TimeSpan.FromMilliseconds(1000)));


        retryPolicy.ExecuteAction(() => client = _factory.CreateTopicClient("test"));
        Console.WriteLine("client Created");
        retryPolicy.ExecuteAction(() => receiver = _factory.CreateSubscriptionClient("test", "App.test"));
        Console.WriteLine("receiver Created");

然后通过

发送
            retryPolicy.ExecuteAction(() => this.client.Send(msg));

当所有服务器都启动时,它可以正常工作。但是当第一个节点关闭并且我们尝试连接到服务总线时,我们得到一个例外,即第一个节点被激活了。

我们缺少什么?

0 个答案:

没有答案