tags:

views:

69

answers:

2

It appears that WAS will call ServiceHostFactory.CreateHost() once per each service implementation. How does WAS manage the lifetime of the ServiceHost/ServiceHostFactory? We have a custom factory/host that is occasionally being re-initialized. I'm wondering if WAS is recycling itself or it has some other reason to re-create the ServiceHostFactory/ServiceHost. I'm guessing the ServiceHostFactory gets fired up for the AppDomain and is a singleton, can someone confirm?

A: 

The WAS manages the activation and lifetime of the worker processes. It manages the message-based activation and worker process recycling, to maintain the app resources. Reading your case, this affirmative is true.

You can use the Single InstanceContext, to handle all client request. Add the following attribute in the contract implementation:

[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]

Also, take a look at the ServiceHost start operation, if is under a static method.

Erup
A: 

After instrumenting WCF, it appears that IIS/WAS will create a ServiceHostFactory per endpoint. From there it will spin up ServiceHosts as it sees fit, as this depends on your configuration.

Adam Fyles