WCF Proxy Caching + runtime endpoint modification

152 views Asked by At

The project I am currently working in, we have over 30 wcf services, which are called a lot in our web application, we ran into performance issues and once of the solutions was to cache the proxy. So what we did is create a dictionary object and using the endpoint name as key, cached the channel factory object so that subsequent calls will pull from the cache rather than re-instantiating the channel factory object at every call. There are many implementations over on other forums.

But we ran into one issue, the way our system is setup is that our services reside on one or more servers, of which only one is active at any one time, if a server fails then another is used as a fail safe. When creating the channel factory before putting into the cache, we can get the latest endpoint address for a given service and then instantiate it. However in this scenario, if a server fails and we pull a channel factory object from the cache, it'll refer to an old endpoint address.

I was checking on forums whether it was possible to update the endpoint address in channel factory object, if this was doable I could update the channel factory object in the cache and use it from then, I don't think this is possible.

The only thing I came up with recently is, that we check for a possible 404 fault exception which will happen when an old endpoint address is hit, then get the latest endpoint address and recreate the channel factory, and update that in the cache.

If you guys have any other ideas, would be helpful. Kinda stuck at this point.

1

There are 1 answers

0
Sergei Namniasov On

You can create the channel factory without specifying an endpoint address and pass it to the method CreateChannel later:

public TChannel CreateChannel(EndpointAddress address)