クラス ConnectionFactoryUtils
java.lang.ObjectSE
org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils
Spring ベースの Rabbit
ConnectionFactory を管理するためのヘルパークラス。特に、特定の ConnectionFactory のトランザクション Rabbit リソースを取得するためのものです。 主にフレームワーク内での内部使用のため。RabbitTemplate および SimpleMessageListenerContainer で使用されます。
- 作成者:
- Mark Fisher, Dave Syer, Gary Russell, Artem Bilan
ネストされたクラスの要約
ネストされたクラスメソッドのサマリー
修飾子と型メソッド説明static @Nullable RabbitResourceHolderbindResourceToTransaction(RabbitResourceHolder resourceHolder, ConnectionFactory connectionFactory, boolean synched) static voidトランザクション同期を使用する場合、トランザクションのコミット後にこのメソッドを呼び出して、RabbitMQ トランザクションがコミットされたことを確認します。static ConnectioncreateConnection(ConnectionFactory connectionFactory, boolean publisherConnectionIfPossible) この接続ファクトリおよび / またはそのパブリッシャーファクトリとの接続を作成します。static voidenableAfterCompletionFailureCapture(boolean enable) トランザクション同期の使用時にAfterCompletionFailedExceptionのキャプチャーを有効にするには、このメソッドを呼び出します。static RabbitResourceHoldergetTransactionalResourceHolder(ConnectionFactory connectionFactory, boolean synchedLocalTransactionAllowed) 現在のトランザクションと同期されている RabbitMQ チャネルを取得します (存在する場合)。static RabbitResourceHoldergetTransactionalResourceHolder(ConnectionFactory connectionFactory, boolean synchedLocalTransactionAllowed, boolean publisherConnectionIfPossible) 現在のトランザクションと同期されている RabbitMQ チャネルを取得します (存在する場合)。static booleanisChannelTransactional(com.rabbitmq.client.Channel channel, ConnectionFactory connectionFactory) 指定された RabbitMQ チャネルがトランザクション対応であるかどうか、つまり、Spring のトランザクション機能によって現在のスレッドにバインドされているかどうかを判断します。static voidregisterDeliveryTag(ConnectionFactory connectionFactory, com.rabbitmq.client.Channel channel, LongSE tag) static voidreleaseResources(@Nullable RabbitResourceHolder resourceHolder)
メソッドの詳細
isChannelTransactional
public static boolean isChannelTransactional(com.rabbitmq.client.Channel channel, ConnectionFactory connectionFactory) 指定された RabbitMQ チャネルがトランザクション対応であるかどうか、つまり、Spring のトランザクション機能によって現在のスレッドにバインドされているかどうかを判断します。- パラメーター:
channel- 確認する RabbitMQ チャネルconnectionFactory- Channel の元となった RabbitMQ ConnectionFactory- 戻り値:
- チャネルがトランザクションかどうか
getTransactionalResourceHolder
public static RabbitResourceHolder getTransactionalResourceHolder(ConnectionFactory connectionFactory, boolean synchedLocalTransactionAllowed) 現在のトランザクションと同期されている RabbitMQ チャネルを取得します (存在する場合)。- パラメーター:
connectionFactory- チャネルを取得するための ConnectionFactorysynchedLocalTransactionAllowed- Spring 管理のトランザクション (たとえば、メイントランザクションが特定の DataSource 用の JDBC ベースのトランザクションである場合) と同期されるローカル RabbitMQ トランザクションを許可するかどうか。RabbitMQ トランザクションはメイントランザクションの直後にコミットされます。許可されていない場合、指定された ConnectionFactory はカバーでトランザクションの登録を処理する必要があります。- 戻り値:
- トランザクションチャネル、または見つからない場合は
null
getTransactionalResourceHolder
public static RabbitResourceHolder getTransactionalResourceHolder(ConnectionFactory connectionFactory, boolean synchedLocalTransactionAllowed, boolean publisherConnectionIfPossible) 現在のトランザクションと同期されている RabbitMQ チャネルを取得します (存在する場合)。- パラメーター:
connectionFactory- チャネルを取得するための ConnectionFactorysynchedLocalTransactionAllowed- Spring 管理のトランザクション (たとえば、メイントランザクションが特定の DataSource 用の JDBC ベースのトランザクションである場合) と同期されるローカル RabbitMQ トランザクションを許可するかどうか。RabbitMQ トランザクションはメイントランザクションの直後にコミットされます。許可されていない場合、指定された ConnectionFactory はカバーでトランザクションの登録を処理する必要があります。publisherConnectionIfPossible- 可能であれば、別のパブリッシャー接続から接続を取得します。- 戻り値:
- トランザクションチャネル、または見つからない場合は
null
releaseResources
bindResourceToTransaction
public static @Nullable RabbitResourceHolder bindResourceToTransaction(RabbitResourceHolder resourceHolder, ConnectionFactory connectionFactory, boolean synched) enableAfterCompletionFailureCapture
public static void enableAfterCompletionFailureCapture(boolean enable) トランザクション同期の使用時にAfterCompletionFailedExceptionのキャプチャーを有効にするには、このメソッドを呼び出します。例外はThreadLocalSE に格納され、トランザクションの完了後にcheckAfterCompletion()を呼び出してクリアする必要があります。- パラメーター:
enable- キャプチャーを有効にする場合は true。
checkAfterCompletion
public static void checkAfterCompletion()トランザクション同期を使用する場合、トランザクションのコミット後にこのメソッドを呼び出して、RabbitMQ トランザクションがコミットされたことを確認します。- 例外:
AfterCompletionFailedException- 同期に失敗した場合。- 導入:
- 2.3.10
registerDeliveryTag
public static void registerDeliveryTag(ConnectionFactory connectionFactory, com.rabbitmq.client.Channel channel, LongSE tag) createConnection
public static Connection createConnection(ConnectionFactory connectionFactory, boolean publisherConnectionIfPossible) この接続ファクトリおよび / またはそのパブリッシャーファクトリとの接続を作成します。- パラメーター:
connectionFactory- 接続ファクトリ。publisherConnectionIfPossible- パブリッシャーファクトリが存在する場合、それを使用する場合は true。- 戻り値:
- 接続。
- 導入:
- 2.0.2