Manipulating order of XA resources

155 views Asked by At

Is there a way to manipulate the order of executing the registered XAResources within a transaction for quarkus? In my scenario I have a database datasource and an ActiveMQ resource within the XA transaction configured. For me it seems that there is no defined order which resource is handled first and which last during the two-phase-commit.

My issue is that sometimes the final commit is done first to the messaging system, so that event of service A is published before the database has finished it's final commit - the event is handled by another service B that tries to fetch data from service A - in rare cases service B receives data from service A that is of state before event publishing cause final commit of two-phase-commit on db is still in progress.

IMO the best solution would be to handle the ActiveMQ resource always as second (or last) resource within the two-phase-commit.

1

There are 1 answers

0
geca On

We're experiencing the same issues after migrating from Thorntail. It seems Narayana (transaction manager that is used by Quarkus) does not support ordering as per this (albeit old) thread on JBoss Community Archive. The author of the comment states that ordering can be done by resource implementing the org.jboss.tm.FirstResource but we have not tried that yet.

Our solution for now is using a delay via _AMQ_SCHED_DELIVERY property on JMS message to give DB enough time to commit before the message is consumed.