Scrivio Interview library
ScenarioIntermediate7 min read · updated 12 November 2026

A legacy Java EE application uses JTA with XA transactions spanning an Oracle database and an IBM MQ queue. You are moving it to Spring Boot on Kubernetes. Would you keep XA, and what are the alternatives?

We can keep XA in Spring Boot with a standalone JTA transaction manager such as Narayana or Atomikos, but on Kubernetes it needs a durable transaction log on persistent storage and a stable identity per pod for recovery, and it costs latency and lock time. In most migrations I would replace it: a transactional outbox in Oracle with a relay to IBM MQ, or best-effort one-phase commit with idempotent consumers, keeping XA only for a flow where neither is acceptable.

Why this question is asked

Many enterprise Java EE systems were built on the application server's JTA support, and XA transactions between a database and a message queue were the normal way to get atomic send-and-save. Moving such a system to Spring Boot on Kubernetes forces the question of whether that still makes sense. Interviewers ask it because a good answer weighs a working, proven mechanism against its operational cost in a very different runtime. In this answer, we will recap what the XA setup does today, see what it takes to keep it, look at the Kubernetes-specific problems and the general costs, and then compare the alternatives and decide.

1A Quick Recap of What XA Does Here

JTA, the Jakarta Transactions API, lets one transaction manager coordinate several resources. XA is the standard interface those resources implement so they can take part in two-phase commit: each resource prepares and votes, then all commit or all roll back. In the legacy application, a message-driven bean receives a message from IBM MQ, updates Oracle and maybe sends a reply message, and the application server's transaction manager commits the MQ receive, the Oracle update and the send atomically.

The benefit is real. If Oracle fails, the message goes back to the queue; if MQ fails, Oracle rolls back. The application code never handles partial failure. That is what we would be giving up, so the alternatives must handle it some other way.

2Keeping XA in Spring Boot

Spring Boot has no application server, so we bring a standalone JTA transaction manager. The two common choices are Narayana, the transaction manager from WildFly, and Atomikos. Spring Boot used to auto-configure Atomikos itself; in Spring Boot 3 that built-in support was removed, so today we use the starter each project provides. Check what your Spring Boot version supports directly before choosing.

We configure XA-capable connection factories, the Oracle XA DataSource and the IBM MQ XA connection factory, register them with the transaction manager, and use Spring's JtaTransactionManager so @Transactional and the JMS listener container join the same global transaction.

Java
@Bean
JtaTransactionManager transactionManager(UserTransaction ut, TransactionManager tm) {
return new JtaTransactionManager(ut, tm); // backed by Narayana or Atomikos
}
@JmsListener(destination = "PAYMENTS.IN")
@Transactional // MQ receive + Oracle update + MQ send: one XA transaction
public void on(PaymentInstruction msg) {
paymentRepository.apply(msg);
jmsTemplate.convertAndSend("PAYMENTS.OUT", Ack.of(msg));
}

This works, and for a lift-and-shift with tight deadlines it can be the lowest-risk first step. The question is what it costs to run.

3Why XA Is Awkward on Kubernetes

XA depends on recovery. When the transaction manager crashes after participants have prepared, it must restart, read its transaction log and finish every in-doubt transaction by committing or rolling back. Until then Oracle and MQ hold locks and in-doubt messages. That log must survive the crash, so it needs a persistent volume, not the pod's ephemeral disk.

Recovery also needs a stable identity: the restarted process must be the same transaction manager node, because participants record the node id with each in-doubt transaction. Ordinary Deployments give pods random names and new disks. So we would run the service as a StatefulSet with a persistent volume claim per pod and a node id derived from the pod's ordinal. Scaling down becomes risky: if pod 3 is removed while it owns in-doubt transactions, nobody recovers them. Rolling restarts, node evictions and autoscaling, which Kubernetes does freely, all become operations we have to think about.

XA on an application server versus on Kubernetes
NeedApplication serverKubernetes
Durable transaction logserver's local diskpersistent volume per pod
Stable node identityfixed server nameStatefulSet ordinal
Recovery after crashsame server restartssame pod must return with its volume
Scale downrare, plannedmust drain in-doubt work first
Autoscalingnot usedconflicts with recovery ownership
Every row is solvable, but each one is work that the alternatives do not need.

4The General Costs of XA

Apart from Kubernetes, XA has costs anywhere. Every commit needs a prepare round trip to each resource plus a log write, which can add several milliseconds per transaction. Locks are held from the start until the second phase completes, which lowers throughput under contention. And support varies: some drivers, connection pools and managed cloud services support XA poorly or not at all, and a future move to a managed broker or database may simply not offer it.

That last point matters for a migration that is supposed to last ten years. Choosing XA ties the design to resources that support it.

5The Alternatives

The first alternative is a transactional outbox. The service writes its Oracle change and an outbox row in one local Oracle transaction. A relay reads the outbox and sends to IBM MQ, marking rows as sent, retrying on failure. Every committed change produces a message at least once, with no XA at all. For the inbound side, the consumer stores the incoming message id in a processed-messages table in the same Oracle transaction as its work, so a redelivered message is recognised and skipped.

The second is best-effort one-phase commit: receive the message, commit Oracle, then acknowledge the message. If the process dies after the Oracle commit but before the acknowledgement, MQ redelivers it, and the dedup table makes the second attempt a no-op. If it dies before the Oracle commit, the message is redelivered and processed normally. With idempotent consumers this is often enough, and it is far simpler to run.

Java
@JmsListener(destination = "PAYMENTS.IN") // session-transacted: ack only after return
@Transactional // local Oracle transaction only
public void on(PaymentInstruction msg) {
if (!processed.insertIfAbsent(msg.messageId())) return; // duplicate after redelivery: skip
paymentRepository.apply(msg);
outbox.add("PAYMENTS.OUT", Ack.of(msg)); // relay sends it later
} // Oracle commits; then the JMS session commits the receive

Notice that the order of commits is chosen on purpose: the database first, the message acknowledgement second. A failure between them leads to a redelivery, never to a lost update, and the dedup table absorbs the redelivery.

6What I Would Choose

I would not keep XA by default. For most flows I would move to the outbox plus idempotent consumers, because it runs on ordinary Deployments, scales and restarts freely, and does not depend on XA support in future infrastructure. For a flow that truly cannot tolerate even a duplicate attempt and cannot be made idempotent, which is rare, I would keep XA for that one service, run as a StatefulSet with persistent logs, and document its recovery procedure. If the deadline is tight, keeping XA first and replacing it flow by flow afterwards is a valid plan, as long as the replacement is actually scheduled.

7Follow-up questions

How would you test recovery after a crash between prepare and commit?

I would reproduce it on purpose in a test environment. Most transaction managers let us inject a fault after prepare, or we can use a debugger or a test participant that pauses after voting yes, then kill the pod with kill -9 at that point. After restart we check that the transaction manager finds the in-doubt transaction in its log, completes it, Oracle shows the committed row or none, MQ shows the message consumed or back on the queue, and no locks remain. We also test the nasty case: the pod comes back on a different node with its volume, and the case where the volume is lost, to know what manual steps are needed.

Is the outbox slower than XA?

For the business transaction it is usually faster, because it is one local commit with no prepare phase. The message leaves a little later, after the relay picks up the row, typically within a second. If downstream latency matters, CDC on the outbox table or a short relay interval keeps that delay small.

8Conclusion

In this answer, we saw that XA can be kept in Spring Boot with Narayana or Atomikos and JtaTransactionManager, but on Kubernetes it needs a persistent transaction log and stable pod identity for recovery, which fights scaling and restarts, and it adds latency and lock time everywhere. The alternatives are a transactional outbox with a relay to MQ, and best-effort one-phase commit, commit the database then acknowledge the message, both relying on idempotent consumers. I would choose those for most flows and keep XA only where nothing else works.

What to say in the interviewAbout 90 seconds aloud

Open with

I would not keep XA by default, though it is possible. Spring Boot has no application server, so I would need a standalone JTA transaction manager such as Narayana or Atomikos with JtaTransactionManager and XA connection factories for Oracle and IBM MQ.

Then, if they want more

Spring Boot 3 removed its own Atomikos support, so I would check what my version supports directly. The real problem is running it on Kubernetes.

XA recovery needs a durable transaction log and a stable node identity, so the service has to be a StatefulSet with a persistent volume per pod, and scaling down or losing a pod with in-doubt transactions leaves locks in Oracle and MQ until someone recovers them.

XA also adds a prepare round trip and longer lock hold times, and not every driver or managed service supports it well. The alternatives are simpler. For outbound messages, a transactional outbox: write the Oracle change and an outbox row in one local transaction, and a relay sends to MQ with retries.

For inbound messages, best-effort one-phase commit: commit Oracle first, then acknowledge the message, and keep a processed-message table so a redelivery after a crash is skipped. With idempotent consumers that covers almost every flow. I would keep XA only for a flow that cannot be made idempotent, and test its recovery by killing the pod between prepare and commit.

About this answer

Last updated
12 November 2026
Versions it names
Spring Boot 3
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "A legacy Java EE application uses JTA with XA transactions spanning an Oracle database...": https://scrivio-interview-library.netlify.app/spring-boot/distributed-data/a58a358990/