A couple months ago I wrote a post on how to host WCF services in IIS that expose themselves as endpoints on the Windows Azure AppFabric Service Bus. The principal challenge in this scenario is that IIS/WAS relies on message-based activation and will only launch the host after the first request comes in. However, until the host is launched the service will not connect to the Service Bus, and consequently will never receive a message. A classic catch-22.
The solution I proposed was to leverage the Application Warm-Up Extension for IIS 7.5, which will proactively load and initialize processes before the first request arrives. While this is acceptable, I’ve found a better solution using the Windows Server AppFabric Autostart (thanks to conversations with Ron Jacobs).
Windows Server AppFabric Autostart is a feature introduced in Windows 7 and Windows Server 2008 R2. The primary use cases are for reducing the latency incurred by the first message and to host WCF transports/protocols for which their are no listener adapters. As you can see, initializing the host so that it connects to the Service Bus is another benefit.
To set this up, ensure that you have installed Windows Server AppFabric on your machine. I personally recommend you use the Web Platform Installer to do this for you (I detail how to do this in the first part of my post on Getting Started with Windows Server AppFabric Cache). Once you have this installed, follow these steps:
Open IIS Manager. Navigate to your web application.
Click on Configure in Actions pane.
Configure the application to either autostart all the services by choosing Enabled or specific services by choosing Custom.
If you specified Custom, navigate to the configuration panel for that specific service and turn autostart to Enabled.
Pretty straightforward. I think you’ll like this solution, as it keeps everything within the AppFabric family.