AppFabric AutoStart feature is built on top of IIS 7.5 AutoStart feature. IIS 7.5 provides an extensibility point where you can specify your custom initialization providers which will be executed as part of application start-up and gives you the ability to perform costly initialization. For example, pre-populating an AppFabric cache.
Windows Server AppFabric uses this extensibility point to implement the AutoStart feature for WCF & Workflow Services (XAMLX). As part of AppFabric installation, it registers a custom AutoStartProvider which is responsible for activating all the services configured for AutoStart. Here is a simple flow diagram…
Activation of WCF/Workflow Services results in calling the ServiceHostFactory associated with the service to return an instance of the ServiceHost which would ultimately host the service and make it available to the clients. This behaviour opens up an option where you could put your costly initialization inside the custom ServiceHostFactory directly rather than using the IIS 7.5 extensibility. CreateServiceHost method of your custom factory will be invoked as soon as AppFabric auto starts your service.
public class CustomXamlxHostFactory : WorkflowServiceHostFactory
protected override WorkflowServiceHost CreateWorkflowServiceHost(WorkflowService service, Uri baseAddresses)
var host = base.CreateWorkflowServiceHost(service, baseAddresses);
// Initialization logic: Populate AppFabric cache etc..
In .NET 4.0, a custom ServiceHostFactory can be easily associated with a service using the <serviceActivations> element in the web.config.
Check out my earlier post for additional details…
Original post by Zulfiqar Ahmed on 26th November 2010 here: http://zamd.net/2010/11/26/initializing-auto-start-wcfworkflow-services/