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)

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

適用対象