Tuesday 4 June 2013

"Always Running" WCF Service

A WCF service hosted in IIS is activated whenever a message is received. It processes the message, and then the service implementation is available for garbage collection. If the application pool is idle for more than the timeout period (with a default of 20 minutes), then the worker processes serving the pool are terminated.

Some services may need to perform some pre-work before they begin accepting requests (like loading in some static data). They may want to activate the application pool before any requests are made to ensure there is no delay when the first request comes in. This can be done with the AlwaysRunning settings on the application pool.

 But what about hosting a Service Bus application in IIS? A Service Bus client must create a connection to the server and keep it open for the duration of the lifetime of the application. The request-based activation does not work here.

This article describes how the application pool is automatically started, how an AutoStart Provider is used to invoke startup code to create a connection to the service bus, and how the service is restarted in the event of an application pool stopping.

References
Death to Windows Services - Long Live AppFabric

No comments:

Post a Comment