Hi,
we are currently evaluating Axon 3.0.5 for our needs on a new project and I have a conceptual question regarding publishing events as reaction on events applied to the aggregate.
The scenario is rather simple: We have two aggregates, equipments and customers, and equipments can be assigned to one customer - the customer aggregate does not store which equipments are assigned.
Now I want to react on a EquipmentAssignedToCustomerCommand, which applies to the equipment updating its assigned customer (EquipmentAssignedEvent), and this resulting in another published event which unassigns the equipment from the former customer.
@EventSourcingHandler public void on(EquipmentAssignedEvent event) { logActivity(event); if (this.assignedCustomerId != null) { eventService .publish(GenericEventMessage.asEventMessage( new EquipmentUnassignedFromCustomerEvent(this.id, this.assignedCustomerId)) ); } this.assignedCustomerId = event.getCustomerId(); }
The example itself does work the way intended, but then I realized that on event replay for creating the snapshotEvents, the EquipmentUnassignedEvent gets published a second time (and how many times there are updates between snapshots.
Do I make a conceptional mistake here?