Does quarkus support distributed transactions? #35257
Unanswered
1017727621
asked this question in
Q&A
Replies: 4 comments
|
Did anyone reply to me? |
0 replies
|
Quarkus does not support distributed transactions (XA) in the traditional JTA sense. The reactive and imperative architectures favor the Saga pattern instead. Why: Quarkus prioritizes non-blocking, reactive, and cloud-native design. Distributed transactions with 2PC (two-phase commit) block resources and don't scale horizontally. Alternatives:
@ApplicationScoped
public class OrderSaga {
@Inject
OrderService orderService;
@Inject
PaymentService paymentService;
@Inject
InventoryService inventoryService;
@Transactional
public void placeOrder(Order order) {
try {
orderService.create(order); // step 1
paymentService.charge(order.getAmount()); // step 2
inventoryService.reserve(order.getItems()); // step 3
} catch (Exception e) {
// Compensating actions
if (order.getId() != null) orderService.cancel(order.getId());
// Payment auto-reverses or call cancel
// Inventory auto-releases
throw new RuntimeException("Saga failed", e);
}
}
}
@Entity
public class OutboxEvent {
@Id UUID id;
String aggregateType;
String aggregateId;
String eventType;
@Lob String payload;
boolean published;
}
// Write to outbox in the same transaction as your business logic
// Debezium or similar reads the outbox and publishes to Kafka
# application.properties
quarkus.transaction-manager.enable-recovery=true
quarkus.datasource.jdbc.transactions=xaBut this is not recommended for reactive or high-throughput systems. Use Sagas + messaging for distributed consistency. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Description
(Describe the feature here.)
Implementation ideas
(If you have any implementation ideas, they can go here, however please note that all design change proposals should be posted to the Quarkus developer mailing list (or the corresponding Google Group; see the decisions process document for more information).
All reactions