संपादित करें

इसके माध्यम से साझा किया गया


ReceiveErrorHandling Enum

Definition

Specifies handling for poison messages.

public enum class ReceiveErrorHandling
public enum ReceiveErrorHandling
type ReceiveErrorHandling = 
Public Enum ReceiveErrorHandling
Inheritance
ReceiveErrorHandling

Fields

Name Value Description
Fault 0

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.

Drop 1

This option drops the poison message. The message never gets delivered to the application. 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.

Reject 2

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.

Move 3

This moves the poison message to a Poison Message Queue for later processing by a poison message handling application.

Examples

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>

Remarks

A poison message is a message that fails repeated attempts to deliver to the application. This is applicable only when using a Message Queuing (MSMQ)-based binding. The default value is Fault, which faults the listener and therefore the ServiceHost. In the case where the service was to fault because of a poison message, a MsmqPoisonMessageException is thrown. 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. Certain values of the ReceiveErrorHandling enumeration such as Reject and Move are only available on Windows Vista. You control poison message handling by setting the ReceiveErrorHandling property to one of the values of this enumeration.

Applies to

See also