クラス ReactiveMongoTransactionManager
java.lang.ObjectSE
org.springframework.transaction.reactive.AbstractReactiveTransactionManager
org.springframework.data.mongodb.ReactiveMongoTransactionManager
- 実装済みのインターフェース一覧:
SerializableSE, InitializingBean, ConfigurableTransactionManager, ReactiveTransactionManager, TransactionManager
public class ReactiveMongoTransactionManager
extends AbstractReactiveTransactionManager
implements InitializingBean
単一の
ReactiveMongoDatabaseFactory の ClientSession ベースのトランザクションを管理する ReactiveTransactionManager 実装。 指定された ReactiveMongoDatabaseFactory から ClientSession をサブスクライバー Context にバインドします。Readonly トランザクションは ClientSession で動作し、因果一貫性を有効にします。また、start、commit、または abort トランザクションも動作し、因果一貫性を有効にします。
アプリケーションコードでは、標準の ReactiveMongoDatabaseFactory.getMongoDatabase() 呼び出しではなく、ReactiveMongoDatabaseUtils.getDatabase(ReactiveMongoDatabaseFactory) を介して MongoDatabase を取得する必要があります。ReactiveMongoTemplate などの Spring クラスは、この戦略を暗黙的に使用します。デフォルトでは、コミット操作が失敗すると TransactionSystemException が発生します。MongoDB リファレンスマニュアルに記載されているように、doCommit(TransactionSynchronizationManager, ReactiveMongoTransactionObject) をオーバーライドしてコミット操作を再試行しますの動作を実装できます。
- 導入:
- 2.2
- 作成者:
- Christoph Strobl, Mark Paluch
- 関連事項:
ネストされたクラスの概要
ネストされたクラス修飾子と型クラス説明protected static classMongoResourceHolderを表す MongoDB 固有のトランザクションオブジェクト。クラス AbstractReactiveTransactionManager から継承されたネストクラス / インターフェース
AbstractReactiveTransactionManager.SuspendedResourcesHolderフィールド概要
クラス AbstractReactiveTransactionManager から継承されたフィールド
loggerコンストラクター概要
コンストラクターコンストラクター説明Bean スタイルの使用のために新しいReactiveMongoTransactionManagerを作成します。ReactiveMongoTransactionManager(ReactiveMongoDatabaseFactory databaseFactory) 指定されたReactiveMongoDatabaseFactoryからセッションを取得する新しいReactiveMongoTransactionManagerを作成します。ReactiveMongoTransactionManager(ReactiveMongoDatabaseFactory databaseFactory, @Nullable com.mongodb.TransactionOptions options) 新しいトランザクションを開始するときに、指定されたoptions(存在する場合) を適用して、指定されたReactiveMongoDatabaseFactoryからセッションを取得し、新しいReactiveMongoTransactionManagerを作成します。ReactiveMongoTransactionManager(ReactiveMongoDatabaseFactory databaseFactory, MongoTransactionOptionsResolver transactionOptionsResolver, @Nullable MongoTransactionOptions defaultTransactionOptions) 新しいトランザクションを開始するときに、指定されたoptions(存在する場合) を適用して、指定されたReactiveMongoDatabaseFactoryからセッションを取得し、新しいReactiveMongoTransactionManagerを作成します。方法の概要
修飾子と型メソッド説明voiddoBegin(TransactionSynchronizationManager synchronizationManager, ObjectSE transaction, TransactionDefinition definition) doCleanupAfterCompletion(TransactionSynchronizationManager synchronizationManager, ObjectSE transaction) doCommit(TransactionSynchronizationManager synchronizationManager, ReactiveMongoTransactionManager.ReactiveMongoTransactionObject transactionObject) 指定されたトランザクションの実際のコミットを実行するためのカスタマイズフック。
コミット操作でエラーが発生した場合、MongoDB ドライバーはエラーラベルを保持するMongoExceptionをスローします。doCommit(TransactionSynchronizationManager synchronizationManager, GenericReactiveTransaction status) protected ObjectSEdoGetTransaction(TransactionSynchronizationManager synchronizationManager) doResume(TransactionSynchronizationManager synchronizationManager, @Nullable ObjectSE transaction, ObjectSE suspendedResources) doRollback(TransactionSynchronizationManager synchronizationManager, GenericReactiveTransaction status) doSetRollbackOnly(TransactionSynchronizationManager synchronizationManager, GenericReactiveTransaction status) doSuspend(TransactionSynchronizationManager synchronizationManager, ObjectSE transaction) @Nullable ReactiveMongoDatabaseFactoryこのインスタンスがトランザクションを管理するReactiveMongoDatabaseFactoryを取得します。protected booleanisExistingTransaction(ObjectSE transaction) voidsetDatabaseFactory(ReactiveMongoDatabaseFactory databaseFactory) このインスタンスがトランザクションを管理するReactiveMongoDatabaseFactoryを設定します。voidsetOptions(@Nullable com.mongodb.TransactionOptions options) トランザクションを開始するときに適用するTransactionOptionsを設定します。クラス AbstractReactiveTransactionManager から継承されたメソッド
commit, getReactiveTransaction, getTransactionExecutionListeners, prepareForCommit, registerAfterCompletionWithExistingTransaction, rollback, setTransactionExecutionListenersクラス ObjectSE から継承されたメソッド
clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSEインターフェース ConfigurableTransactionManager から継承されたメソッド
addListener
コンストラクターの詳細
ReactiveMongoTransactionManager
public ReactiveMongoTransactionManager()Bean スタイルの使用のために新しいReactiveMongoTransactionManagerを作成します。
注意 : インスタンスを使用する前に、db factoryをsetDatabaseFactory(ReactiveMongoDatabaseFactory)に設定する必要があります。このコンストラクターを使用して、BeanFactoryを介してReactiveMongoTransactionManagerを準備します。
オプションで、ReadConcernとWriteConcernを定義してデフォルトのtransaction optionsを設定することもできます。- 関連事項:
ReactiveMongoTransactionManager
指定されたReactiveMongoDatabaseFactoryからセッションを取得する新しいReactiveMongoTransactionManagerを作成します。- パラメーター:
databaseFactory- null であってはなりません。
ReactiveMongoTransactionManager
public ReactiveMongoTransactionManager(ReactiveMongoDatabaseFactory databaseFactory, @Nullable com.mongodb.TransactionOptions options) 新しいトランザクションを開始するときに、指定されたoptions(存在する場合) を適用して、指定されたReactiveMongoDatabaseFactoryからセッションを取得し、新しいReactiveMongoTransactionManagerを作成します。- パラメーター:
databaseFactory- null であってはなりません。options- null にすることができます。null の場合はデフォルトでMongoTransactionOptions.NONEになります。
ReactiveMongoTransactionManager
public ReactiveMongoTransactionManager(ReactiveMongoDatabaseFactory databaseFactory, MongoTransactionOptionsResolver transactionOptionsResolver, @Nullable MongoTransactionOptions defaultTransactionOptions) 新しいトランザクションを開始するときに、指定されたoptions(存在する場合) を適用して、指定されたReactiveMongoDatabaseFactoryからセッションを取得し、新しいReactiveMongoTransactionManagerを作成します。- パラメーター:
databaseFactory- null であってはなりません。transactionOptionsResolver- null であってはなりません。defaultTransactionOptions- null にすることができます。null の場合はデフォルトでMongoTransactionOptions.NONEになります。- 導入:
- 4.3
方法の詳細
doGetTransaction
protected ObjectSE doGetTransaction(TransactionSynchronizationManager synchronizationManager) throws TransactionException isExistingTransaction
- オーバーライド:
- クラス
AbstractReactiveTransactionManagerのisExistingTransaction - 例外:
TransactionException
doBegin
protected Mono<VoidSE> doBegin(TransactionSynchronizationManager synchronizationManager, ObjectSE transaction, TransactionDefinition definition) throws TransactionException - 次で指定:
- クラス
AbstractReactiveTransactionManagerのdoBegin - 例外:
TransactionException
doSuspend
protected Mono<ObjectSE> doSuspend(TransactionSynchronizationManager synchronizationManager, ObjectSE transaction) throws TransactionException - オーバーライド:
- クラス
AbstractReactiveTransactionManagerのdoSuspend - 例外:
TransactionException
doResume
protected Mono<VoidSE> doResume(TransactionSynchronizationManager synchronizationManager, @Nullable ObjectSE transaction, ObjectSE suspendedResources) - オーバーライド:
- クラス
AbstractReactiveTransactionManagerのdoResume
doCommit
protected final Mono<VoidSE> doCommit(TransactionSynchronizationManager synchronizationManager, GenericReactiveTransaction status) throws TransactionException - 次で指定:
- クラス
AbstractReactiveTransactionManagerのdoCommit - 例外:
TransactionException
doCommit
protected Mono<VoidSE> doCommit(TransactionSynchronizationManager synchronizationManager, ReactiveMongoTransactionManager.ReactiveMongoTransactionObject transactionObject) 指定されたトランザクションの実際のコミットを実行するためのカスタマイズフック。
コミット操作でエラーが発生した場合、MongoDB ドライバーはエラーラベルを保持するMongoExceptionをスローします。
デフォルトではこれらのラベルは無視されますが、transient commit errors labelsをチェックしてコミットを再試行することもできます。- パラメーター:
synchronizationManager- リアクティブ同期マネージャー。transactionObject- 決して null にはなりません。
doRollback
protected Mono<VoidSE> doRollback(TransactionSynchronizationManager synchronizationManager, GenericReactiveTransaction status) - 次で指定:
- クラス
AbstractReactiveTransactionManagerのdoRollback
doSetRollbackOnly
protected Mono<VoidSE> doSetRollbackOnly(TransactionSynchronizationManager synchronizationManager, GenericReactiveTransaction status) throws TransactionException - オーバーライド:
- クラス
AbstractReactiveTransactionManagerのdoSetRollbackOnly - 例外:
TransactionException
doCleanupAfterCompletion
protected Mono<VoidSE> doCleanupAfterCompletion(TransactionSynchronizationManager synchronizationManager, ObjectSE transaction) - オーバーライド:
- クラス
AbstractReactiveTransactionManagerのdoCleanupAfterCompletion
setDatabaseFactory
このインスタンスがトランザクションを管理するReactiveMongoDatabaseFactoryを設定します。- パラメーター:
databaseFactory- null であってはなりません。
setOptions
public void setOptions(@Nullable com.mongodb.TransactionOptions options) トランザクションを開始するときに適用するTransactionOptionsを設定します。- パラメーター:
options- null でもかまいません。
getDatabaseFactory
このインスタンスがトランザクションを管理するReactiveMongoDatabaseFactoryを取得します。- 戻り値:
- null でもかまいません。
afterPropertiesSet
public void afterPropertiesSet()- 次で指定:
- インターフェース
InitializingBean内のafterPropertiesSet