thorphin
thorphin

Reputation: 118

How to throttle services with the Castle Windsor WCF Facility?

In out of the box with WCF it is easy to throttle your services on an individual basis via the app.config or in code (using the behavior configuration) . I can't figure our how to do this in Castle.

In Castle I do know how to throttle all of my services in a container with this code:

var throttle = new ServiceThrottlingBehavior() { MaxConcurrentCalls = 2 }; container.Register(Component.For<IServiceBehavior>().Instance(throttle));

The problem with this code is it applies to ALL services registered in the container.

How in Castle Windsor can I throttle each service on an individual basis?

Upvotes: 2

Views: 169

Answers (1)

moarboilerplate
moarboilerplate

Reputation: 1643

Since the ApplyDispatchBehavior() method gets called every time this behavior is getting wired up to a service, you can write code inside this event to inspect the service object and conditionally apply the behavior or not. So it'll call this method for every service, but will do nothing for the services you don't want this behavior to apply to.

Short of that, I haven't found another way.

Upvotes: 2

Related Questions