WCF 服务太忙
服务是否正在工作,但是当数据库出现故障时,应用程序池最终会停止。
在服务方面,我们对连接到数据库的所有代码都进行了尝试/捕获错误异常。
我正在寻找有关如何通过服务控制来减少此类错误的提示,因为我们无法控制服务器。
如果需要更多详细信息,请告诉我,我将更新帖子。
自定义客户端提供程序:
public class ClientWCFProvider<TT> : IDisposable
{
private ChannelFactory<TT> channel;
public TT WCF { get; set; }
public ClientWCFProvider(string service)
{
channel = GetServiceChannel(service);
WCF = channel.CreateChannel();
}
private ChannelFactory<TT> GetServiceChannel(string service)
{
BasicHttpBinding serviceBinding = new BasicHttpBinding();
//set the config on the bindings for timeouts etc.
serviceBinding.MaxReceivedMessageSize = 105190152;
serviceBinding.MaxBufferSize = Convert.ToInt32(serviceBinding.MaxReceivedMessageSize);
serviceBinding.OpenTimeout = new TimeSpan(0, 3, 0);
serviceBinding.SendTimeout = new TimeSpan(0, 3, 0);
EnvironmentDescriptor serviceEnvironment;
EndpointAddress ServiceEndpoint;
... code to setup the endpoint
ServiceChannel = new ChannelFactory<TT>(serviceBinding, ServiceEndpoint);
return ServiceChannel;
}
public void Dispose()
{
((IClientChannel)WCF).Close();
channel.Close();
}
}
然后像这样调用服务:
using(var x = new ClientWCFProvider<TT>("NameOfService"))
{
...
}
Are services are working, but when the Database goes down, the application pool ends up stopping.
On the service side, we have try/catch with Fault Execeptions for all code connecting to the databases.
I'm looking for an tips on how to reduce these type of errors from the control of the services, as we do not have control over the servers.
Please let me know if more details are needed, and I'll update the posting.
Custom Client-Side Provider:
public class ClientWCFProvider<TT> : IDisposable
{
private ChannelFactory<TT> channel;
public TT WCF { get; set; }
public ClientWCFProvider(string service)
{
channel = GetServiceChannel(service);
WCF = channel.CreateChannel();
}
private ChannelFactory<TT> GetServiceChannel(string service)
{
BasicHttpBinding serviceBinding = new BasicHttpBinding();
//set the config on the bindings for timeouts etc.
serviceBinding.MaxReceivedMessageSize = 105190152;
serviceBinding.MaxBufferSize = Convert.ToInt32(serviceBinding.MaxReceivedMessageSize);
serviceBinding.OpenTimeout = new TimeSpan(0, 3, 0);
serviceBinding.SendTimeout = new TimeSpan(0, 3, 0);
EnvironmentDescriptor serviceEnvironment;
EndpointAddress ServiceEndpoint;
... code to setup the endpoint
ServiceChannel = new ChannelFactory<TT>(serviceBinding, ServiceEndpoint);
return ServiceChannel;
}
public void Dispose()
{
((IClientChannel)WCF).Close();
channel.Close();
}
}
Then the services are called like this:
using(var x = new ClientWCFProvider<TT>("NameOfService"))
{
...
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基于 ErnieL 的最终解决方案是这样的: http://blog.davidbarrett.net/archive /2007/11.aspx
The end solution, based on ErnieL is this: http://blog.davidbarrett.net/archive/2007/11.aspx