1

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 purposes. 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

Everything Matters
  • 2,672
  • 4
  • 25
  • 42

2 Answers2

1

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.

Roy Dictus
  • 32,551
  • 8
  • 60
  • 76
  • In both the options, as I understand, I should change every opertion method in each of the services, to check the status and then accordingly proceed or not. I am afraid, I will not be able to do that at the moment, since we have around 10 or more services and 100's of methods in them. Your first option seems to get me thinking but am not sure how can I control the other end points of the service through this end point. – Everything Matters Jun 30 '11 at 08:40
  • You could use message interception in both methods to allow or disallow the operations. You can find out more about that at http://msdn.microsoft.com/en-us/library/ms751495.aspx. – Roy Dictus Jun 30 '11 at 12:40
0

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.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • I dont mean a readonly mode. I want the services to be running but after the admin locks the services, when any further client tried to access the service it should throw an error or may be indicate that the service is in locked state. Hope it is clear. – Everything Matters Jun 29 '11 at 10:58
  • @Mani - then presumably the extension points; in particular the invoker. But no - nothing built in. – Marc Gravell Jun 29 '11 at 11:13