ISinglePhaseNotification 接口
定义
描述支持单阶段提交优化以参与事务的资源对象。Describes a resource object that supports single phase commit optimization to participate in a transaction.
public interface class ISinglePhaseNotification : System::Transactions::IEnlistmentNotification
public interface ISinglePhaseNotification : System.Transactions.IEnlistmentNotification
type ISinglePhaseNotification = interface
interface IEnlistmentNotification
Public Interface ISinglePhaseNotification
Implements IEnlistmentNotification
- 实现
注解
请注意,即使资源管理器实现此接口以支持单阶段提交优化,也不能保证它收到单阶段提交。You should note that even when your resource manager implements this interface to support single phase commit optimization, it is not guaranteed that it receives a single phase commit. 事务管理器仍可以改为发送两阶段提交通知。The transaction manager can still send two phase commit notifications instead.
若要在事务中登记资源管理器作为参与者,请调用 EnlistVolatile 方法或 EnlistDurable 类的方法 Transaction 。To enlist your resource manager as a participant in a transaction, call the EnlistVolatile method or the EnlistDurable method of the Transaction class. 具体而言, EnlistmentOptions 参数应该等于, None 以确保执行单阶段提交。Specifically, the EnlistmentOptions parameter should equal to None to ensure that a single phase commit is performed. 如果错误地将其设置为 EnlistDuringPrepareRequired ,则不会发生单阶段提交。If it is mistakenly set to EnlistDuringPrepareRequired, no single phase commit occurs.
由于 ISinglePhaseNotification 接口派生自 IEnlistmentNotification 接口,因此,资源管理器还必须实现后两阶段提交通知的所有方法。Since the ISinglePhaseNotification interface derives from the IEnlistmentNotification interface, the resource manager must also implement all the methods of the latter for two phase commit notifications. 事务管理器的选择是将两阶段提交还是单阶段提交优化用于此资源管理器。It is the transaction manager's choice as to whether two phase commit or the single phase commit optimization is used with this resource manager. 但是,实现此接口会使资源管理器有机会在可用时使用优化。However, implementing this interface gives the resource manager the opportunity to take advantage of the optimization when it is available.
如果使用了优化并且事务管理器调用 SinglePhaseCommit 了登记资源的方法,则资源管理器应使用类的各种方法来响应此调用, SinglePhaseEnlistment 以便在事务提交或回滚时通知事务管理器。If the optimization is used and the transaction manager calls the SinglePhaseCommit method of the enlisted resource, the resource manager should respond to this call by using various methods of the SinglePhaseEnlistment class to inform the transaction manager if the transaction is to be committed or rolled back.
方法
| Commit(Enlistment) |
通知登记的对象事务正在提交。Notifies an enlisted object that a transaction is being committed. (继承自 IEnlistmentNotification) |
| InDoubt(Enlistment) |
通知登记的对象事务的状态不确定。Notifies an enlisted object that the status of a transaction is in doubt. (继承自 IEnlistmentNotification) |
| Prepare(PreparingEnlistment) |
通知登记的对象事务正在为提交做准备。Notifies an enlisted object that a transaction is being prepared for commitment. (继承自 IEnlistmentNotification) |
| Rollback(Enlistment) |
通知登记的对象事务正在回滚(中止)。Notifies an enlisted object that a transaction is being rolled back (aborted). (继承自 IEnlistmentNotification) |
| SinglePhaseCommit(SinglePhaseEnlistment) |
表示资源管理器的用于单阶段提交优化的回调实现。Represents the resource manager's implementation of the callback for the single phase commit optimization. |