ReceiveErrorHandling 枚举

定义

指定对有害消息的处理。Specifies handling for poison messages.

public enum class ReceiveErrorHandling
public enum ReceiveErrorHandling
type ReceiveErrorHandling = 
Public Enum ReceiveErrorHandling
继承
ReceiveErrorHandling

字段

Drop 1

此选项可删除病毒消息。This option drops the poison message. 消息始终没有传递到应用程序。The message never gets delivered to the application. 如果此时消息的 TTL 已过期,则此消息就会出现发送端的死信队列中。If the message's TTL had already expired at this point, then the message may appear in the sender's Dead Letter Queue. 如果不是这种情况,则该消息将不会显示在任何位置。If not, the message does not appear anywhere. 此选项指示用户实际并不在意该消息是否丢失。This option indicates that the user does not really care if the message is lost.

Fault 0

此选项会向导致 ServiceHost 出现错误的侦听器发送一个错误。This option sends a fault to the listener that caused the ServiceHost to fault. 必须利用其他一些外部机制将该消息从应用程序中移除,应用程序才能继续处理队列中的消息。The message must be removed from the application queue by some external mechanism before the application can continue to process messages from the queue.

Move 3

选择此选项会将病毒消息移动到病毒消息队列,以供以后由病毒消息处理应用程序进行处理。This moves the poison message to a Poison Message Queue for later processing by a poison message handling application.

Reject 2

选择此选项会指示消息队列 (MSMQ) 将否定确认发送回发送队列管理器,以说明应用程序无法接收此消息。This instructs MSMQ to send a negative acknowledgement back to the sending queue manager that the message cannot be received by the application. 该消息会放入发送队列管理器的死信队列中。The message is placed in the sending queue manager's Dead Letter Queue.

示例

下面的配置代码演示如何在服务配置文件中设置该属性:The following configuration code illustrates how to set this property in the service configuration file:

<configuration>
  <appSettings>
    <!-- use appSetting to configure MSMQ queue name -->
    <add key="queueName" value=".\private$\ServiceModelSamplesPoison" />
    <add key="baseAddress" value="http://localhost:8000/orderProcessor/poisonSample"/>
  </appSettings>
  <system.serviceModel>
    <services>
      <service 
              name="Microsoft.ServiceModel.Samples.OrderProcessorService">
        <!-- Define NetMsmqEndpoint -->
        <endpoint address="net.msmq://localhost/private/ServiceModelSamplesPoison"
                  binding="netMsmqBinding"
                  bindingConfiguration="PoisonBinding" 
                  contract="Microsoft.ServiceModel.Samples.IOrderProcessor" />
      </service>
    </services>

    <bindings>
      <netMsmqBinding>
        <binding name="PoisonBinding" 
                 receiveRetryCount="0"
                 maxRetryCycles="1"
                 retryCycleDelay="00:00:05" 					 
                 receiveErrorHandling="Fault"
                        />
      </netMsmqBinding>
    </bindings>
  </system.serviceModel>
</configuration>

注解

病毒消息是一种无法重复传递到应用程序的消息。A poison message is a message that fails repeated attempts to deliver to the application. 这仅在使用基于消息队列 (MSMQ) 的绑定时适用。This is applicable only when using a Message Queuing (MSMQ)-based binding. 默认值为 Fault,此时侦听器会出错,ServiceHost 也会因此出错。The default value is Fault, which faults the listener and therefore the ServiceHost. 如果服务因为病毒消息而出错,则会引发 MsmqPoisonMessageExceptionIn the case where the service was to fault because of a poison message, a MsmqPoisonMessageException is thrown. 该异常含有 MSMQ 消息的 LookupId,可用于通过 System.Messaging API 将消息移除。The exception contains the LookupId of the MSMQ message that can be used to move the message out of the way using System.Messaging API. ReceiveErrorHandling 枚举的某些值,例如 RejectMove 仅在 Windows VistaWindows Vista 上可用。Certain values of the ReceiveErrorHandling enumeration such as Reject and Move are only available on Windows VistaWindows Vista. ReceiveErrorHandling 属性设置为该枚举的其中一个值可以控制病毒消息处理。You control poison message handling by setting the ReceiveErrorHandling property to one of the values of this enumeration.

适用于

另请参阅