views:

444

answers:

3
+1  Q: 

Robust WCF service

What is the best way to ensure service robustness to prevent a service becoming unavailable, if it does become unavaliable is there a way of restarting the service?

thanks in advance.

+1  A: 

Use a hosting technique. You can self host in a windows service, and place the faulted event to trigger the service to close. You can then use windows to restart your service.

Or if you have windows 2008 you can use WAS to host your service, which will automatically restart it.

It's important to realise that your service may have state, but there is no "thread" that is running in it, so it's not running as such, the object merely exists. You are basically paying microsoft to provide .net and WCF to you which looks after the hosting side of things, they guarantee to you that your service will remain available.

A crash in a method would fault the service, but you can handle any exceptions which you can deal with gracefully and let the operating system deal with things that you can't (such as out of memory exceptions etc.) Note it is your responsibility to deal with the service faulting. Beyond that however WCF is extremely robust.

Spence
A: 

That depends on the way you host your service.

An explanation and comparison of the different available options can be found here: http://msdn.microsoft.com/en-us/library/ms730158.aspx

David Tischler
A: 

Just for clarity, If for whatever reason I didn't handle an exception and this triggered the service to terminate, under IIS 7.0 the service should restart in a new state.

CodeMonkey
If you don't handle the exception, it will trigger your service to fault. YOU are responsible to clean it up and force it to close or "unfault" it.
Spence