Best practices for scheduling and cancelling deadlines

What are best practices concerning scheduling and cancelling deadlines using the DeadlineManager and Quartz?

Context about our application (Spring Boot + Axon + Quartz):
It’s concerning an application with one big Aggregate and two smaller AggregateMembers (no entities).
Currently, deadlines are scheduled in different tracked projections (each scheduling / cancelling deadlines for a specific deadlineName).
I’m trying to move the scheduling/cancelling to the Aggregate or AggregateMembers itself.

Facts about our events & deadlines:

  • Events that result in a deadline are applied at multiple places throughout both the Aggregate as the AggregateMember (i.e. by different CommandHandlers)
  • Same for Events that result in cancellation of a deadline
  • All deadlines are scheduled with a provided scheduleId, sometimes it is an id (of the aggregate), sometimes it’s a generated random UUID.
  • Sometimes we use the same scheduleId (aggregateId) for different deadlines (i.e. different deadlineNames).

Hi Anne,

just to make sure we’re talking about the same thing, I want to clarify the term “Aggregate”, “Aggregate Member” and “Entity”. Essentially, an Aggregate is a group of entities. In Axon, you need to mark the Aggregate Root (the entity that is the “entry point” towards the Aggregate) with @Aggregate. Fields referencing Entities that you want to participate in the Axon messaging need to be annotated with @AggregateMember. So in fact, all @AggregateMembers are actually Entities.

For Axon, the entire Aggregate (the Aggregate Root as well as any of its declared Members) is considered “one unit”. So it doesn’t really matter where in the Aggregate you schedule a deadline. The Event triggered when the deadline expires is made available for all entities within the Aggregate.

That makes the best practice a modeling exercise. The best solution is the one that gives you the nicest model to work with.

I hope this helps.
Cheers,