Created
August 1, 2011 06:44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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