GH-1362: Enable Capture of Tx Synchronization Fail

Resolves https://github.com/spring-projects/spring-amqp/issues/1362

**cherry-pick to 2.3.x**

* Add missing doc changes.

* Fix test to reset flag.
This commit is contained in:
Gary Russell
2021-07-16 18:52:50 -04:00
committed by Artem Bilan
parent 10929b7b40
commit 032f8ecee7
4 changed files with 116 additions and 2 deletions

View File

@@ -5673,6 +5673,17 @@ If you prefer XML configuration, you can declare the following bean in your XML
----
====
[[tx-sync]]
===== Transaction Synchronization
Synchronizing a RabbitMQ transaction with some other (e.g. DBMS) transaction provides "Best Effort One Phase Commit" semantics.
It is possible that the RabbitMQ transaction fails to commit during the after completion phase of transaction synchronization.
This is logged by the `spring-tx` infrastructure as an error, but no exception is thrown to the calling code.
Starting with version 2.3.10, you can call `ConnectionUtils.checkAfterCompletion()` after the transaction has committed on the same thread that processed the transaction.
It will simply return if no exception occurred; otherwise it will throw an `AfterCompletionFailedException` which will have a property representing the synchronization status of the completion.
Enable this feature by calling `ConnectionFactoryUtils.enableAfterCompletionFailureCapture(true)`; this is a global flag and applies to all threads.
[[containerAttributes]]
==== Message Listener Container Configuration