Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Order of JMS TransactionSynchronizations should be sortable programmatically [SPR-16491] #21034
When i was reading thru code and documentation i found JmsResourceSynchronization and TransactionSynchronizationManager that are in middle of this functionality.
If i understand code correctly then while triggering afterCommit, JpaTransactionManager gets list of sorted TransactionSynchronization and sorting is done with AnnotationAwareOrderComparator.sort(). My observation is that order of commit/rollback is based on order in which JMS messages was send (and registered inside TransactionSynchronizationManager).
Because most methods are static and JmsResourceSynchronization is private, only what i can currently do is ugly and unreliable workaround like this:
List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager.getSynchronizations(); TransactionSynchronizationManager.clearSynchronization(); TransactionSynchronizationManager.initSynchronization(); synchronizations = Lists.reverse(synchronizations); synchronizations.forEach(TransactionSynchronizationManager::registerSynchronization);
If this sorting of same implementation of TransactionSynchronization (in my case JmsResourceSynchronization) can be done programmatically from