質問

I'm having a hard time understanding how it is possible to host a same service on 2 different hosts on the same URI using service bus. Essentially, this is how we host the service.

    try
        {
            uri = ServiceBusEnvironment.CreateServiceUri(UriSchemeSb, this.serviceBusDescriptor.ServiceNamespace, servicePath);
            host = new ServiceHost(serviceType);
            host.AddServiceEndpoint(interfaceType, this.relayBinding, uri);
            AddSharedSecretServiceBusCredentialBehavior(host, this.serviceBusDescriptor.IssuerName, this.serviceBusDescriptor.IssuerKey);

            this.host.Open();
        }
        catch (SecurityTokenException exception)
        {
            this.host.Abort();
            this.host = null;               
        }

It can happen that there two hosts with the same servicePath, and both services get hosted on the same URI.

I thought that some exception will be thrown, but it seems that is not the case. Did I misunderstood something or is it expected behavior to have a newly generated guid in the URI for every service that is hosted?

Any suggestions other than testing the URI before hosting the service?

役に立ちましたか?

解決

You are using the Load Balancing feature of Service Bus in that case. You can have multiple hosts hosting the same endpoint (up to 20 listeners per endpoint), which can be beneficial in high load scenarios (round-robin style) or high availability scenarios (one host is down, other continues to process) Hope this makes sense?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top