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();
}

注釈

この動作で構成されるトランスポートは、複数の受信操作を 1 つのトランザクションにバッチ処理しようとします。 これを実行することにより、受信操作のたびに行うトランザクションの作成とそのコミットの比較的高いコストを回避できます。

コンストラクター

TransactedBatchingBehavior(Int32)

指定したバッチ サイズを使用して、TransactedBatchingBehavior クラスの新しいインスタンスを初期化します。

プロパティ

MaxBatchSize

1 回のトランザクションでまとめてバッチ処理できる受信操作の最大数を取得または設定します。

メソッド

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)

トランザクション受信操作をサポートするバインディングにのみトランザクション バッチが適用されることを確認します。 このメソッドは継承できません。

適用対象