EnlistmentOptions 枚举


确定是否应该在准备阶段登记该对象。Determines whether the object should be enlisted during the prepare phase.

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class EnlistmentOptions
public enum EnlistmentOptions
type EnlistmentOptions = 
Public Enum EnlistmentOptions


EnlistDuringPrepareRequired 1

该对象必须在提交过程的初始阶段中进行登记。The object must enlist during the initial phase of the commitment process.

None 0

该对象在提交过程的初始阶段中不需要登记。The object does not require enlistment during the initial phase of the commitment process.


此枚举将传递到EnlistVolatileEnlistDurable和方法, 以通知事务管理器, 资源管理器是否需要在准备阶段创建另一个登记。This enumeration is passed into the EnlistVolatile and EnlistDurable and methods to notify the transaction manager whether the resource manager needs to create another enlistment during the Prepare phase. 有关登记的详细信息, 请参阅在事务中将资源登记为参与者For more information on enlistment, see Enlisting Resources as Participants in a Transaction.

如果在登记期间指定了 EnlistDuringPrepareRequired, 则资源管理器会指示它想要接收准备通知, 同时仍允许为事务使用新的登记。If EnlistDuringPrepareRequired is specified during enlistment, the resource manager indicates that it wants to receive a Prepare notification while new enlistments are still allowed for the transaction. 充当其他持久资源 (如后端数据库) 的缓存的资源管理器可能会在登记期间使用此选项。A resource manager who acts as a cache for another durable resource, such as a backend database, would probably use this option during enlistment. 当缓存资源获取其准备通知时, 它会将其内容传输到持久资源。When the caching resource gets its Prepare notification, it transfers its content to the durable resource. 这样一来, 持久资源将在事务上登记, 以成为2阶段提交 (2PC) 协议的参与者。By doing so, the durable resource enlists on the transaction to become a participant of the 2 Phase Commit (2PC) protocol. 在此之前, 只登记了缓存资源 (而非持久资源)。Before this happens, only the caching resource (not the durable resource) was enlisted.

如果未指定任何内容, 则登记会指示它将不会收到准备通知, 直到在2PC 中创建新的登记。If None is specified, the enlistment indicates that it will not receive a Prepare notification until it is too late to create new enlistments in 2PC. 在前面的方案中, 如果缓存资源在登记期间指定此选项, 并在准备通知期间尝试刷新其缓存, 则持久资源会在其尝试登记时获取异常, 因为它太晚。In our preceding scenario, if a caching resource specifies this option during enlistment, and attempts to flush its cache during the Prepare notification, the durable resource gets an exception when it attempts on enlisting since it is too late.

"无" 应用作默认值。None should be used as a default.