简体   繁体   English

强大的WCF服务

[英]Robust WCF service

What is the best way to ensure service robustness to prevent a service becoming unavailable, if it does become unavaliable is there a way of restarting the service? 确保服务稳健性以防止服务不可用的最佳方法是什么(如果确实不可用),是否可以重新启动服务?

thanks in advance. 提前致谢。

Use a hosting technique. 使用托管技术。 You can self host in a windows service, and place the faulted event to trigger the service to close. 您可以自行托管Windows服务,然后放置发生故障的事件以触发服务关闭。 You can then use windows to restart your service. 然后,您可以使用Windows重新启动服务。

Or if you have windows 2008 you can use WAS to host your service, which will automatically restart it. 或者,如果您使用Windows 2008,则可以使用WAS托管服务,它将自动重新启动它。

It's important to realise that your service may have state, but there is no "thread" that is running in it, so it's not running as such, the object merely exists. 重要的是要认识到您的服务可能具有状态,但是其中没有正在运行的“线程”,因此它并不是这样运行的,对象只是存在。 You are basically paying microsoft to provide .net and WCF to you which looks after the hosting side of things, they guarantee to you that your service will remain available. 您基本上是向Microsoft付费,以向您提供.net和WCF来托管事物,它们向您保证您的服务将保持可用。

A crash in a method would fault the service, but you can handle any exceptions which you can deal with gracefully and let the operating system deal with things that you can't (such as out of memory exceptions etc.) Note it is your responsibility to deal with the service faulting. 方法崩溃会导致服务故障,但是您可以处理可以妥善处理的所有异常,并让操作系统处理您无法处理的异常(例如内存不足异常等)。请注意,这是您的责任处理服务故障。 Beyond that however WCF is extremely robust. 除此之外,WCF非常强大。

That depends on the way you host your service. 这取决于您托管服务的方式。

An explanation and comparison of the different available options can be found here: http://msdn.microsoft.com/en-us/library/ms730158.aspx 可以在这里找到不同的可用选项的说明和比较: http : //msdn.microsoft.com/zh-cn/library/ms730158.aspx

只是为了清楚起见,如果出于某种原因我没有处理异常,并且这触发了服务终止,则在IIS 7.0下,该服务应以新状态重新启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM