我如何prevent从进入故障状态WCF服务? [英] How do I prevent a WCF service from enter a faulted state?

查看:141
本文介绍了我如何prevent从进入故障状态WCF服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不应该进入故障状态WCF服务。如果有一个例外,它应该被记录,服务应不间断地继续。该服务有一个单向操作合同,是从读MSMQ消息。

我的问题是双重的:

  1. 在该服务似乎是吞咽 异常/故障,所以我不能 调试它。我如何得到最好的服务 揭露例外,让我 可以记录或处理呢?
  2. 在该服务 进入后,故障状态 这个例外是吞下。怎么办 我prevent服务进入 进入故障状态?
解决方案

大多数,如果不是所有异常可以在WCF跟踪可以看到(的配置跟踪)和跟踪是最好的服务跟踪观察浏览器

显然,这不是你应该已经在生产环境中运行的所有的一天,但它有助于排除故障呢。

除此之外,注意oneways可能不是一个真正的运行射后不理,这取决于您使用的SessionMode。如果已经配置了SessionMode.Allowed甚至SessionMode.Required您服务,单向操作将运行,如果它是不是在所有单向(可使用oneways在NetTcpBinding的时候可以观察到)。坦率地说,不过,我不知道这是否改变了异常,你可以得到的类型,或当您得到他们。然而,在任何情况下,你应该得到一个例外,如果要求不能发送的。 AFAIK的单向结束时,它成功enqued在服务器端。因此,有一些地方(WCF框架相关的)异常直到那时(序列化/反序列化想到)。

那么,这样的框架相关的异常,最好看到使用上述跟踪/ traceviewer(甚至IErrorHandler没有得到他们全部因时,它是所谓的请求/响应流的事实)。

I have a WCF Service that should not enter the faulted state. If there's an exception, it should be logged and the service should continue uninterrupted. The service has a one-way operation contract and is reading messages from an MSMQ.

My problems are twofold:

  1. The service appears to be swallowing an exception/fault so I am unable to debug it. How do I get the service to expose the exception so that I can log or handle it?
  2. The service is entering into a faulted state after this exception is swallowed. How do I prevent the service from entering into a faulted state?

解决方案

Most, if not all exceptions can be seen in the WCF Trace (Configuring Tracing) and the trace is best viewed with the Service Trace Viewer.

Obviously, this is not something you should have running all day in a production environment, but it helps in troubleshooting anyway.

Apart from that, note that oneways may not run as a true "fire and forget" depending on the SessionMode you use. If you have your service configured for SessionMode.Allowed or even SessionMode.Required, the oneway operation will run as if it was not oneway at all (this can be observed when using oneways over the netTcpBinding). To be frank, however, I don't know if that changes the type of exceptions you can get, or when you get them. However, in any case, you should get an exception if the request could not be send at all. AFAIK, the oneway "ends" when it is successfully enqued on the server side. So there is some place for (WCF framework related) exceptions until then (serialization/deserialization comes to mind).

Then, such framework related exceptions are best seen (even an IErrorHandler doesn't get them all due to the fact when it is called in the request/response-flow) using the above mentioned trace / traceviewer.

这篇关于我如何prevent从进入故障状态WCF服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆