Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order of JMS TransactionSynchronizations should be sortable programmatically [SPR-16491] #21034

spring-projects-issues opened this issue Feb 13, 2018 · 0 comments
in: data in: messaging type: enhancement


Copy link

@spring-projects-issues spring-projects-issues commented Feb 13, 2018

Ludovit Varga opened SPR-16491 and commented

I have application that consume message from JMS Server A, update row in database and produce messages to multiple JMS queues on different servers. This must be done in transaction and without JTA. Application is written with Spring Boot 2.0.0.M7 (with Spring 5.0.2) with data-jpa and jms starters.

Application can't use JTA transactions (requirement from client), so I implemented Best effort 1PC pattern. It works nicely but client needs to have specific order of commit/rollback of JMS transactions. In my case he required that outbound messages are committed first and then are committed inbound message.

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();
synchronizations = Lists.reverse(synchronizations);

If this sorting of same implementation of TransactionSynchronization (in my case JmsResourceSynchronization) can be done programmatically from @Configuration classes, that would be great.

Affects: 5.0.2

@spring-projects-issues spring-projects-issues added in: messaging in: data type: enhancement labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 5.x Backlog milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: data in: messaging type: enhancement
None yet

No branches or pull requests

1 participant