IBindingDeliveryCapabilities.AssuresOrderedDelivery 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得值,這個值指出繫結是否可以支援保證能夠以訊息傳送的順序來傳遞訊息。
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 屬性的值。 執行這項檢查的目的是要判斷,是否可由針對服務選取或建立的繫結來滿足此服務的排序傳遞需求。