IBindingDeliveryCapabilities.AssuresOrderedDelivery 属性

定义

获取一个值,该值指示绑定是否可以支持按消息发送顺序传递消息的保证。

public:
 property bool AssuresOrderedDelivery { bool get(); };
public bool AssuresOrderedDelivery { get; }
member this.AssuresOrderedDelivery : bool
Public ReadOnly Property AssuresOrderedDelivery As Boolean

属性值

true 如果消息必须按发送顺序传递, false,如果消息可能未按此顺序传递。

示例

下面的示例要求 CalculatorService 必须对有序邮件传递使用 WSHttpBinding 。 默认情况下,不使用此绑定使用可靠会话和排队传递,但可以启用。

<!-- Here is the configuration for a CalculatorService using a WSHttpBinding with ordered message delivery required. -->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <system.serviceModel>
      <services>
         <service
             type="Microsoft.ServiceModel.Samples.CalculatorService">
            <!-- Use base address provided by host and a WSHttpBinding named "Binding1" -->
            <endpoint address=""
                      binding="wsHttpBinding"
                      bindingConfiguration="Binding1"
                      contract="Microsoft.ServiceModel.Samples.ICalculator" />
         </service>
      </services>

      <bindings>
         <wsHttpBinding>
            <binding name="Binding1">
               <!-- The next element enables a ReliableSession and required ordered delivery-->
      <reliableSession enabled="true" ordered="true"/>
      </binding>
         </wsHttpBinding>
      </bindings>

   </system.serviceModel>
</configuration>

// The CalculatorService configuration has enabled a reliable session
// with ordered delivery set to true. This means that the binding
// requirement for ordered delivery specified by the
// BindingRequirementsAttribute on the CalculatorService class
// implemented below will be satisfied by this WSHttpBinding.

using System;
using System.ServiceModel;

[ServiceContract]
interface ICalculatorService
{
  [OperationBehavior()]
  int Add(int a, int b);

  [OperationContract]
  int Subtract(int a, int b);
}

[BindingRequirements(
  QueuedDeliveryRequirements=RequirementsMode.Disallow,
  RequireOrderedDelivery=true
)]
class CalculatorService: ICalculatorService
{
  public int Add(int a, int b)
  {
    Console.WriteLine("Add called.");
    return a + b;
  }

  public int Subtract(int a, int b)
  {
    Console.WriteLine("Subtract called.");
    return a - b;
  }

  public int Multiply(int a, int b)
  {
    return a * b;
  }
}

注解

当在运行时加载服务说明时,此属性的值 AssuresOrderedDelivery 将消耗 RequireOrderedDelivery 。 完成此检查以确定为服务选择的绑定还是为服务创建的绑定满足服务的有序传递要求。

适用于