Skip to content

Instantly share code, notes, and snippets.

Created November 22, 2011 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1385842 to your computer and use it in GitHub Desktop.
Save anonymous/1385842 to your computer and use it in GitHub Desktop.
UserRegistrationSaga
class UserRegistrationSaga {
private RegistrationStep registrationStep;
... // Other stuff
@SagaStart
@SagaEventHandler(UserCreated event){
commandBus.dispatch(new SendAConfirmationEmailToUser());
registrationStep = RegistrationStep.INACTIVE_ACCOUNT_CREATED;
}
@SagaEventHandler(UserConfirmedEmailAddress event){
commandBus.dispatch(new ActivateUserAccount());
registrationStep = RegistrationStep.EMAIL_CONFIRMED;
}
@SagaEventHandler(UserAskedToResendTheConfirmedEmailAddress event){
commandBus.dispatch(new ResendTheConfirmationEmail());
registrationStep = RegistrationStep.CONFIRMATION_EMAIL_RESENT;
}
@EndSaga
@SagaEventHandler(UserAccountActivated event){
commandBus.dispatch(new SendAConfirmationEmailToUser());
registrationStep = RegistrationStep.COMPLETE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment