This documentation is archived and is not being maintained.
TransactedBatchingBehavior Class
Visual Studio 2008
Represents a behavior that optimizes the receive operations for transports that support transactional receives.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
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 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: