There are many good posts out there on how to create a wcf service, so not going to go in any detail, suffice to say that a service contract, its implementation (I like these in there own assemblies, as it makes referencing easier) and a wcf web site with the appropriate service.svc file pointing at your implementation. Then its all config config config. although .net 4 is apparently moving away from the config dependancy i've not had chance to play.
The easiest option by far is to host an http binding service, but there are performance drawbacks, so look at the project its expected use before deciding on this. if you need to pass lots of data or you need speed go with tcp, and although you can load balance net.tcp its easier with http.
net.tcp and net.msmq are a little more involved, first make sure you have installed the non-http wcf component of .net in windows components, then check the nettcpactivator etc services are running, if you have already installed .net 4 you'll have to remove before doing the above as it causes problems. once these are running though its safe to reinstall. Now add the appropriate bindings (with port for tcp eg 9191:* and machine name with queue for msmq). all thats left is to add the protocols. you'll see many posts with command promt lines to copy edit paste and run. i think its far easier to open inetmgr, right click on the parent site, select advanced settings, then manage site and where it says http add ",net.tcp" and/or ",net.msmq" as appropriate (no spaces) then do the same for the app containing your service under the site. I also like to use the same credentials for the app pool and net activator services to avoid any possible issues.
That should be it, the activator services are the listeners and activate the service call when a request hits the server.
One quick note on msmq, you have to create the queue yourself, and unless you really need to advertise the queue on ad (and generally you don't) keep the queue private, the only difference between public and private is that public uses actve directory, if you plan to point your client endpoints at a server name or ip, public is a waste of resources and will hurt performance for no good reason. I have a theory aout load balancing msmq services in iis, and it involves using a horizontal pattern (lots of services on one machine pointing at a single queue, which works very well) with a vertical infrastructure (many machines) by pointing the nodes at a single queue on the primary server which should in theory work. I have a collegue to thank for the idea, and will post soon when i have tested it.
Hi Simon, Have you looked at NServiceBus? - it's built on top of MSMQ and it's really rather nifty :-)
ReplyDelete-- Scott