TransactedBatchingBehavior 類別

定義

表示為支援交易接收的傳輸最佳化接收作業的行為。

public ref class TransactedBatchingBehavior : System::ServiceModel::Description::IEndpointBehavior
public class TransactedBatchingBehavior : System.ServiceModel.Description.IEndpointBehavior
type TransactedBatchingBehavior = class
    interface IEndpointBehavior
Public Class TransactedBatchingBehavior
Implements IEndpointBehavior
繼承
TransactedBatchingBehavior
實作

範例

下列範例會示範如何在組態檔中將交易的批次處理行為加入至服務。

<system.serviceModel>
  <services>
    <service name="Microsoft.ServiceModel.Samples.CalculatorService"
             behaviorConfiguration="CalculatorServiceBehavior">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:8000/ServiceModelSamples/service"/>
        </baseAddresses>
      </host>
     
      <endpoint address="net.msmq://localhost/private/ServiceModelSamples"
                binding="netMsmqBinding"
                contract="Microsoft.ServiceModel.Samples.IQueueCalculator" />
     
      <endpoint address="mex"
                binding="mexHttpBinding"
                contract="IMetadataExchange" />
    </service>
  </services>

  <behaviors>
    <serviceBehaviors>
      <behavior name="CalculatorServiceBehavior">
        <serviceMetadata httpGetEnabled="True"/>
      </behavior>
      <behavior name="transactedBatching" maxBatchSize="10">
      </behavior>
    </serviceBehaviors>
  </behaviors>

</system.serviceModel>

下列範例會示範如何在程式碼中將交易的批次處理行為加入至服務。

// Note: Service class must be marked with [ServiceBehavior(ReleaseServiceInstanceOnTransactionComplete=false)].

Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/service");

// Create a ServiceHost for the CalculatorService type.
using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress))
{
    ServiceEndpoint endpoint;
    endpoint = serviceHost.AddServiceEndpoint(typeof(IQueueCalculator), new NetMsmqBinding(),"net.msmq://localhost/private/ServiceModelSamples");
    endpoint.Behaviors.Add(new TransactedBatchingBehavior(10));

    // Open the ServiceHost to create listeners and start listening for messages.
    serviceHost.Open();

    // The service can now be accessed.
    Console.WriteLine("The service is ready.");
    Console.WriteLine("Press <ENTER> to terminate service.");
    Console.WriteLine();
    Console.ReadLine();

    // Close the ServiceHost to shutdown the service.
    serviceHost.Close();
}

備註

以這個行為設定的傳輸,會嘗試將數個接收作業批次到一個異動中。 如此一來,即可避免在每個接收作業中建立並認可異動時的相對高成本。

建構函式

TransactedBatchingBehavior(Int32)

使用指定的批次大小,初始化 TransactedBatchingBehavior 類別的新執行個體。

屬性

MaxBatchSize

取得或設定可在單一交易中一同進行批次處理的接收作業數目上限。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

IEndpointBehavior.AddBindingParameters(ServiceEndpoint, BindingParameterCollection)

將繫結設定套用至指定的服務端點。 這個方法無法被繼承。

IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint, ClientRuntime)

將異動批次處理行為設定套用至指定的服務端點。 這個方法無法被繼承。

IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint, EndpointDispatcher)

將端點發送器與指定的服務端點相關聯。 這個方法無法被繼承。

IEndpointBehavior.Validate(ServiceEndpoint)

確認交易的批次處理僅適用於支援交易接收作業的繫結。 這個方法無法被繼承。

適用於