Skip to content

Instantly share code, notes, and snippets.

@pawelkaczor
Created August 1, 2011 06:44
class PaymentPeriodSaga extends AbstractSaga {
@StartSaga
@SagaEventHandler(associationProperty = "paymentPeriodId")
public void paymentPeriodCreated(PaymentPeriodCreatedEvent event) {
associateWith("accountId", event.getAccountId());
getEventScheduler().schedule(
// trigger datetime
event.getValidityInterval().getEnd(),
// the event to publish
new PaymentPeriodExpiredEvent(event.getContext(), event.getAggregateId())
);
}
@SagaEventHandler(associationProperty = "paymentPeriodId")
public void paymentPeriodExpired(PaymentPeriodExpiredEvent event) {
RenewAccountCommand command = new RenewAccountCommand.Builder(event.getContext())
.accountId(getAssociatedId("accountId"))
.build();
getCommandBus().dispatch(command);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment