TransactionalEventListener [SPR-17316] #21849
Comments
Juergen Hoeller commented From my point of view, this works as expected since |
clembo590 commented First, thank you for your answer. I updated the attachments with a full project (it only contains the necessary class to test and is very easy). I have 2 "transaction listener" one is "old school" and works the way I would expect it to work. the second is "new school"... and I thought I would be able to replace "old school" by new school and get the same behaviour....
Can you elaborate a bit more on your answer about turning my transaction boundary into an "actual resource transaction"? Thank you
|
clembo590 commented it would be great if you can give me just a few more info...
|
Anthony Vito commented I was experiencing a similar issue. For me it was caused by using Asynchronous events. It looks like the bit of code that registers a callback on the transaction itself wasn't getting a) run on the same thread or b) run before the transaction was gone. In either or both cases, the method annotated TransactionalEventListener would not be executed. Dropping back to fully synchronous events resolves the issue. I don't believe TransactionalEventListener supports asynchronous event handling. |
clembo590 opened SPR-17316 and commented
When using
@TransactionalEventListener
(phase = TransactionPhase.AFTER_COMMIT)public void notificationOnCommit(Data myDataSaved){}
it is possible to receive the event even though the data has not been saved successfully.
I posted an example with the use of normal "``@EventListener
"--> the behaviour is "as expected" because of the use of "TransactionSynchronizationManager.isActualTransactionActive()"
my guess is that when using "
TransactionalEventListener"
it does not work correctly because in the class "ApplicationListenerMethodTransactionalAdapter" the method "onApplicationEvent" is calling "TransactionSynchronizationManager.isSynchronizationActive()" instead of "TransactionSynchronizationManager.isActualTransactionActive()"
Affects: 5.0.8
Attachments:
The text was updated successfully, but these errors were encountered: