Open cer opened 2 years ago
Proposed design consists of additional Saga DSL methods:
notifyParticipant()
withCompensationNotification()
public class NotificationBasedCreateOrderSaga implements SimpleSaga<NotificationBasedCreateOrderSagaData> {
private final SagaDefinition<NotificationBasedCreateOrderSagaData> sagaDefinition;
public NotificationBasedCreateOrderSaga(NotificationBasedCreateOrderSagaSteps steps) {
this.sagaDefinition =
step()
.invokeLocal(steps::createOrder)
.withCompensation(steps::rejectOrder)
.step()
.invokeParticipant(NotificationBasedCreateOrderSagaData::reserveCredit)
.withCompensation(NotificationBasedCreateOrderSagaData::releaseCredit)
.step()
.invokeParticipant(NotificationBasedCreateOrderSagaData::reserveInventory)
.withCompensationNotification(NotificationBasedCreateOrderSagaData::releaseInventory)
.step()
.invokeLocal(steps::approveOrder)
.step()
.notifyParticipant(NotificationBasedCreateOrderSagaData::fulfillOrder)
.build();
}
Various remaining TODOs - see // TODO notifications
Requires: https://github.com/eventuate-tram/eventuate-tram-core/issues/174
Motivation is the concurrent execution of compensating transactions and retriable transactions, which are saga steps that by definition cannot fail.