【发布时间】:2013-08-21 01:35:16
【问题描述】:
我知道我可以使用ServiceThrottlingBehavior 来设置我希望服务支持多少并发会话,但为了得出最佳值,我试图找出在不同时间实际使用的内容那天。我想公开一个服务方法来返回这个实时数据,或者在最小的情况下,记录它。
WCF 服务中是否有任何方法可以查看当前打开和/或处于故障状态的通道数?
【问题讨论】:
-
WCF 支持维护大量性能计数器。你可能想看看那些。
我知道我可以使用ServiceThrottlingBehavior 来设置我希望服务支持多少并发会话,但为了得出最佳值,我试图找出在不同时间实际使用的内容那天。我想公开一个服务方法来返回这个实时数据,或者在最小的情况下,记录它。
WCF 服务中是否有任何方法可以查看当前打开和/或处于故障状态的通道数?
【问题讨论】:
在您“打开”您的 Web 服务后,您的程序或 Windows 服务(无论您如何运行它)应该执行循环来监控您的连接状态。例如,如果连接出现故障,运行 Web 服务的程序将不知道故障,除非您查询 System.ServiceModel.CommunicationState(重复)。
'execution basically stops here to loop through and check the status of host services
While True
For ii = 0 To i - 1 'i = count of started web services, -1 for zero index offset
'check for broken connection case
If objServiceHost(ii).State <> CommunicationState.Opened Then
Throw New Exception("SynchronizationWS Service Host failed.")
Exit While
End If
Next
Threading.Thread.Sleep(1000) 'sleep 1 second before going trying next
End While
你可以试试这样的。
【讨论】: