We are trying to build a proof of concept using Service Bus 1.0 for Windows Server. Right now we have installed the service bus in our development environment on a farm of 3 servers. At this point we have developed a WCF Contract and have pushed messages into a Topic/Subscription model.
My question is what is the recommended approach to load balance our connections using WCF?
var rootAddressManagement = new Uri("sb://[machine1].[domain].local:9354/ServiceBusDefaultNamespace/");
var rootAddressRuntime = new Uri("https://[machine1].[domain].local:9355/ServiceBusDefaultNamespace/");
var machine2AddressManagement = new Uri("sb://[machine2].[domain].local:9354/ServiceBusDefaultNamespace/");
var machine2AddressRuntime = new Uri("https://[machine2].[domain].local:9355/ServiceBusDefaultNamespace/");
var machine3AddressManagement = new Uri("sb://[machine3].[domain].local:9354/ServiceBusDefaultNamespace/");
var machine3AddressRuntime = new Uri("https://[machine3].[domain].local:9355/ServiceBusDefaultNamespace/");
NetworkCredential cred = new NetworkCredential("[DomainUser]", "[Password]", "[Domain].local");
var tokenProvider = TokenProvider.CreateOAuthTokenProvider(new List<Uri> { rootAddressManagement, rootAddressRuntime, machine2AddressManagement, machine2AddressRuntime, machine3AddressManagement, machine3AddressRuntime }, cred);
//Setup Endpoint Information
TransportClientEndpointBehavior behavior = new TransportClientEndpointBehavior(tokenProvider);
ContractDescription contractDesc = ContractDescription.GetContract(typeof([ServiceContract]));
ServiceEndpoint point = new ServiceEndpoint(contractDesc);
point.EndpointBehaviors.Add(behavior);
point.Address = new EndpointAddress("sb://[machine1].[domain].local:9354/ServiceBusDefaultNamespace/[TopicName]");
point.Binding = new NetMessagingBinding("messagingBinding"); //defined in the config
ChannelFactory<[ServiceContract]> factory = new ChannelFactory<[ServiceContract]>(point);
factory.Endpoint.EndpointBehaviors.Add(behavior);
IPingServiceContract clientChannel = factory.CreateChannel();
((IChannel)clientChannel).Open();
This is working to publish on one server, but what happens when it goes down? I would have the same question on the IIS hosted WCF Service that picks these up? Right now the code is pretty much the same above but with the addition of a ListenUri.
What is the recommended approach to load balance here? When using the service bus connection string and manually adding it, it provides the ability to add multiple endpoints.
Thanks in advance!
PS. I was only able to get OAuth authentication programmatically, is it possible to encapsulate all the code above in a config file? That would be preferred.