سؤال

I'm having hard time with NetTcpBinding and timeouts. I know this could be solved by writing Try-Catch-block around every service call and on failure create a new channel with ChannelFactory and make the same call again. Only problem is that there are literately hundreds of places I'd have to do this ugly measure.

I know there has to be a better solution. Unfortunately inheritance is not in my case. Aspects would work, but there's no real support for them in .net..

I was wondering if WCF (channel model?) could be extended in a way that if timeout-exeption is thrown, channel is automatically regenerated (or it tries to reconnect) and the same call is made again. All behind the scenes.

هل كانت مفيدة؟

المحلول

In one of our projects we used a proxy that wraps the real ServiceClient and puts a try-catch around the call to the channel.
when an exception is raised and the channel is faulted we re-open the connection and call again.
we put a threshold that after 3 times of timeout we wont make the call to the same method again.

you can use DynamicProxy or Unity Interceptor for creating this kind of mechanism.
this link might be useful http://kozmic.pl/2009/05/03/wcf-client-proxy-with-castle-dynamic-proxy/

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top