whenever this event happens then that even happens

Here’s an excerpt of an event model for an Identity aggregate:


Is this how you would recommend it be implemented?

class Identity {
  private String accountNumber;
  private String name;
  private int authCode;

  Identity() {}

  Identity(RequestIdentity command) {
    apply(new IdentityRequested(
      command.getAccountNumber(), command.getName(), command.getCell()));

  void on(IdentityRequested event) {
    this.accountNumber = event.getAccountNumber();
    this.name = event.getName();
    this.handleAuthCode(new SendAuthCode(event.getCell()));

  void handleAuthCode(SendAuthCode command) {
    apply(new AuthCodeSent(
      command.getCell(), this.dummyAuthCode()));

  void on(AuthCodeSent event) {
    this.authCode = event.getAuthCode();
  // ...



Hi Wil,

typically, the purple stickies (policies) are implemented in Axon using Sagas or “plain” event handlers. I would be careful having aggregates communicate directly with each other.
The aggregate as you’ve coded it seems fine. In this implementation, the event “AuthCode Sent” must then be handled by a component that actually sends it. In some domains, this may be confusing, as the audit trail says something happened, but was rather the trigger. An alternative would be to apply a AuthCode Requested. The AuthCode Sent is then emitted by whichever component does the actual interaction with the system that sends these codes.

Hope this helps.

Allard Buijze