更改 TransactedReceiveScope 活动中的事务隔离级别
由于数据库中存在锁定问题,我们希望更改 TransactedReceiveScope
隔离级别从 Serialized
到 ReadCommissed
。我们使用 ServiceBehavior
< 来完成此操作/a> 扩展:
public class ReadCommittedServiceBehaviour : BehaviorExtensionElement ,IServiceBehavior
{
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) { }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
serviceDescription.Behaviors.Add(new ServiceBehaviorAttribute() { TransactionIsolationLevel = IsolationLevel.ReadCommitted });
}
public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) {}
public override Type BehaviorType
{
get { return typeof(ReadCommittedServiceBehaviour); }
}
protected override object CreateBehavior()
{
return new ReadCommittedServiceBehaviour();
}
}
我想知道的是...这在 AppFabric 级别是一个好主意吗?我担心持久性数据库中的实例创建。
谢谢
Because we have locking problems in the database we would like to change the TransactedReceiveScope
isolation level from Serializable
to ReadCommitted
. We have done this using a ServiceBehavior
extension:
public class ReadCommittedServiceBehaviour : BehaviorExtensionElement ,IServiceBehavior
{
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) { }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
serviceDescription.Behaviors.Add(new ServiceBehaviorAttribute() { TransactionIsolationLevel = IsolationLevel.ReadCommitted });
}
public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) {}
public override Type BehaviorType
{
get { return typeof(ReadCommittedServiceBehaviour); }
}
protected override object CreateBehavior()
{
return new ReadCommittedServiceBehaviour();
}
}
What I want to know is... is this a good idea at AppFabric level? I am worried about the instance creation in the persistence database.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论