Add the saga module: Saga Pattern in Spring Boot, orchestration vs choreography with Kafka

This commit is contained in:
Claude
2026-10-03 19:56:40 +00:00
parent c1b40b0db9
commit 4a5d3318bf
44 changed files with 1296 additions and 3 deletions
@@ -0,0 +1,34 @@
package com.ankurm.sagademo;
/**
* Every topic this module uses, in one place, so the two coordination styles in the post --
* choreography and orchestration -- never accidentally share a topic. The "choreo." group
* carries plain domain events; the "orch." group splits into commands (the orchestrator telling
* a participant what to do) and replies (the participant reporting back), which is the concrete
* difference between the two styles: choreography has only events, orchestration has commands
* and replies to them.
*/
public final class Topics {
private Topics() {
}
// Choreography: each participant listens for the previous step's event and decides for
// itself what to publish next. No single place knows the whole saga.
public static final String CHOREO_ORDER_CREATED = "choreo.order.created";
public static final String CHOREO_PAYMENT_RESERVED = "choreo.payment.reserved";
public static final String CHOREO_INVENTORY_RESERVED = "choreo.inventory.reserved";
public static final String CHOREO_INVENTORY_REJECTED = "choreo.inventory.rejected";
public static final String CHOREO_PAYMENT_REFUNDED = "choreo.payment.refunded";
public static final String CHOREO_ORDER_CONFIRMED = "choreo.order.confirmed";
public static final String CHOREO_ORDER_CANCELLED = "choreo.order.cancelled";
// Orchestration: the orchestrator issues commands and participants reply; only the
// orchestrator decides what happens next.
public static final String ORCH_CMD_RESERVE_PAYMENT = "orch.cmd.reserve-payment";
public static final String ORCH_REPLY_PAYMENT = "orch.reply.payment";
public static final String ORCH_CMD_RESERVE_INVENTORY = "orch.cmd.reserve-inventory";
public static final String ORCH_REPLY_INVENTORY = "orch.reply.inventory";
public static final String ORCH_CMD_REFUND_PAYMENT = "orch.cmd.refund-payment";
public static final String ORCH_REPLY_REFUND = "orch.reply.refund";
}