TransactedBatchingBehavior 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示优化支持事务接收的传输的接收操作的行为。
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) |
确保事务处理批处理仅适用于支持事务处理接收操作的绑定。 无法继承此方法。 |