TransactedBatchingBehavior Class
Represents a behavior that optimizes the receive operations for transports that support transactional receives.
Namespace: System.ServiceModel.Description
Assembly: System.ServiceModel (in System.ServiceModel.dll)
The TransactedBatchingBehavior type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | TransactedBatchingBehavior | Initializes a new instance of the TransactedBatchingBehavior class with the specified batch size. |
| Name | Description | |
|---|---|---|
![]() | MaxBatchSize | Gets or sets the maximum number of receive operations that can be batched together in one transaction. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() ![]() | IEndpointBehavior.AddBindingParameters | Applies binding settings to the specified service endpoint. This method cannot be inherited. |
![]() ![]() | IEndpointBehavior.ApplyClientBehavior | Applies transaction batching behavior settings to the specified service endpoint. This method cannot be inherited. |
![]() ![]() | IEndpointBehavior.ApplyDispatchBehavior | Associates an endpoint dispatcher with the specified service endpoint. This method cannot be inherited. |
![]() ![]() | IEndpointBehavior.Validate | Ensures that transacted batching is applicable only for the bindings that support transacted receive operation. This method cannot be inherited. |
The following example shows how to add the transacted batching behavior to a service in a configuration file.
<system.serviceModel>
<services>
<service name="Microsoft.ServiceModel.Samples.CalculatorService"
behaviorConfiguration="CalculatorServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/ServiceModelSamples/service"/>
</baseAddresses>
</host>
<!-- Define NetMsmqEndpoint -->
<endpoint address="net.msmq://localhost/private/ServiceModelSamples"
binding="netMsmqBinding"
contract="Microsoft.ServiceModel.Samples.IQueueCalculator" />
<!-- the mex endpoint is explosed at http://localhost:8000/ServiceModelSamples/service/mex -->
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="endpointBehavior">
<transactedBatching maxBatchSize="10" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="CalculatorServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
The following example shows how to add the transacted batching behavior to a service in code.
// 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(); }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
