Question

I have a WCF service and use Spring.ServiceModel.Activation.ServiceHostFactory as a factory in my *.svc. What I need is to load some data into cache when service is called first time or restarted. Could you please suggest a best way to do so? Right now I inherited from the Spring.ServiceModel.Activation.ServiceHostFactory and put my code there but probably should be a better way? Tnx in advance.

Was it helpful?

Solution

We currently have this kind of startup code in the static constructor of our custom ServiceHostFactory. Depending on your settings with regards to the IIS' Application Pool of your service(s) this should be fine.

You need to have a look at the recycling settings of the Application Pool. Once it gets recycled, the static constructor will be called again.

OTHER TIPS

You can use AOP to intercept the call (since you're using Spring already) to get the 'first call' but the most straightforward thing to do would be to call your cache provider in the constructor of your service or some initialization method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top