开发者

Problem making WCF proxies react to service shutdown

I have a custom (generic) proxy class that I use to connect to my WCF services. One of the functionalities I want to provide with this class is the ability to "recover" from service failure (i.e. faulted communcation channels) and shutdown. For this purpose I obtain a reference to the service channel and subscribe to the ICommunicationObject.Closed and ICommunicationObject.Faulted events. When these events occur I start a "recovery" procedure that basically attempts to re-establish a connection to the service every few seconds. The assumption is that if the service becomes unavailable, for whate开发者_Go百科ver reason, it will soon become available again and the client application can pick up where it was.

I have two services. Service A requires a callback contract and service B doesn't. Service A uses a duplex channel, service B doesn't. Both require sessions. Service A implicitly creates a session; service B has IsInitiating and IsTerminating operations defined. Here's the (somewhat confusing) behaviour I see:

Service A

  • Graceful shutdown -> the Faulted event is raised and can be handled by the proxy, but not the Closed event.
  • "Hard" shutdown -> same as above.

Service B

  • Graceful shutdown - no event is raised.
  • "Hard" shutdown - no event is raised.

Note that both services use the same proxy class. The only difference is in how they are initialised. Proxy A uses a duplex channel factory and therefore has to create an instance context to which is passed an instance implementing service A's callback contract. Proxy B simply uses a "regular" channel factory.

Any ideas?

Many thanks, J.


Would the ICommunicationObject.State property help you here? Should return open, closed, faulted, and also the transitional states opening and closing. Perhaps you can check this within your proxy before you call any methods

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜