Six ways to draw a transaction boundary in Java on Spring Boot 4.1: @Transactional, TransactionTemplate, an after-commit listener, the transactional outbox, a Kafka transaction, and a saga instead of XA.
@Transactional
Boot 4.1 wires one transaction manager. It covers that resource, not a broker send in the same method.
TransactionTemplate
Same manager, smaller than the whole method. Still one resource.
After commit
A listener runs only after the database commit. A failure there does not roll the row back.
Outbox
Write the event in the same commit, then relay it. Consumers must skip a duplicate.
Kafka transaction
Atomic inside Kafka. It does not join the database commit.
Saga, not XA
Local transactions across services, with compensation. XA couples what you split.