开发者

stopping user requests to wcf services

开发者 https://www.devze.com 2023-03-15 23:27 出处:网络
I am working on a 3 tier, win form based application with WCF as our service layer. We have around 8 to 10 WCF services (hosted in windows service) for varvious pu开发者_开发技巧rposes. We have a requ

I am working on a 3 tier, win form based application with WCF as our service layer. We have around 8 to 10 WCF services (hosted in windows service) for varvious pu开发者_开发技巧rposes. We have a requirment where in an administrator should be able to lock out the users from doing any operation and then should be able to release lock. Basically, the intention is to do any maintenance and updates to services or DB. One option would be to shutdown the servies. But we also have scenarios where the services cannot be stopped but still we cannot allow any requets to process.

I would like to know, in WCF is there a way or API where we can block the services to take any requests but stil continuing to run.

I am looking at something at the wcf channel level to stop requests going to the services, which could be controlled like an API from a admin UI, rather than changing every service or method. Hope it makes it bit more clearer.

Thanks, Mani


You can have your services expose an Administration endpoint to which you can send Pause/Resume messages.

Alternatively, you can set up a centralized service, say the AuthorizationService, and have your Windows services call the AuthorizationService for every call to make sure it is allowed. Then that service can decide based on user credentials, time of day, mood of the administrator or whatever it wants whether or not to grant the call. I'm not sure this second scenario would be applicable in your particular case.


Blocking "any requests" isn't exactly running. If you mean some kind of read-only mode where your app services queries but not changes, you would have to code that yourself. You might be able to do something fancy via a WCF extension, but I'm not sure I'd bother personally - I'd just check "is the admin flag set" at the start of all the "doing" methods. Or potentially all methods if that is your intent.

You would return a known fault/exception that the caller may (or may not) handle gracefully. If the number of methods is non-trivial, then sure - look to WCF extension points. I'm thinking an "operation behaviour", although there are many extension points.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号