3

I am trying to create a WCF service which is hosted within a windows service. This windows service will be deployed on multiple machines (a variable number of machines depending on load). There will be a business layer which will be queuing "jobs" and passing each job to one of these windows services depending on which one is free.

I am a bit confused on how to achieve this. Do I write the WCF and hosting windows service, install them on to whichever machines I require. Then from the layer which will despatch the jobs to these services, I somehow tell it which machine to send to (via the WCF service interface). It's this bit I am most confused about how to do.

Jonnster
  • 3,094
  • 5
  • 33
  • 45

3 Answers3

4

I have done this exact thing. What you've described is correct (although keeping nodes in sync and not allowing them to step on each other can be rough in a distributed environment). For locating the endpoints, I'd recommend using WS-Discovery as described at http://msdn.microsoft.com/en-us/library/ee354381.aspx. If you're not using .NET4, you can still implement discovery yourself using a service or endpoint behavior.

NateTheGreat
  • 2,295
  • 13
  • 9
  • Thanks for the reply and everyone elses. I have done a lot of this sort of thing using DCOM and C++ but this is my first attempt with .NET and WCF. From reading, I can see that you create a WCF service and then create a host for it. But it seems the host doesn't have to reside on the same machine. Is this true? I was thinking that I create a WCF service and a host and it is both the host and WCF service that reside on each machine and then my client calls whichever one by specifying the machine in it's servicehost constructor (or whatever it is without me going back to my notes). – Jonnster Apr 21 '11 at 08:09
  • No, the host and the WCF service must run on the same machine. Think of the host as your main() method, and the WCF service as a set of objects running in that main method. – NateTheGreat Apr 21 '11 at 12:17
  • Thanks. That is what I thought but I read something online that suggested differently. It didn't make sense to me so thanks for clearing that up. – Jonnster Apr 21 '11 at 15:06
2

Like any other WCF service, your services will expose endpoints. The client will simply send to those endpoints, just like normal.

Perhaps you're unfamiliar with the overloads of the proxy constructor? There are some which accept an endpoint address, permitting the client to choose which service endpoint to use.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
1

You are talking about an NLB solution.

George Polevoy
  • 7,450
  • 3
  • 36
  • 61
  • +1. This is typical problem for dynamic NLB clusters. Just install NLB software (there are few options to choose from) on your central node. Your "business layer" will have to re-configure NLB cluster every time it adds or removes a node. – seva titov Apr 21 '11 at 02:55