John Doe, yes, subscribing to UserCreatedEvent would be fine if your projections are consistent with your event store. Otherwise you’d have to use the service to reserve usernames as well. As for when this code is run, it would flow as follows.
- Command is dispatched.
- Command handler loads aggregate.
- Behavior of aggregate is invoked.
- Validation is run (including usage of the domain service).
- Event is created.
- Event is applied to aggregate.
- Event is stored and dispatched.