Enhancement Description
Pull request #4388 introduces the EntityMetamodel#CREATE_WITHOUT_LOAD ResourceKey to differentiate inside the DefaultEventStoreTransaction. It does so to resolve #4362, which marks the scenario where an entity is created without it being loaded first. This may occur when, for example, a command does not carry a @TargetEntityId for a creational command handler (which is a perfectly valid scenario).
Although this ResourceKey works, it's quite hacky. We jump from the EntityCommandHandlingComponent in axon-modelling, where this is set, to the DefaultEventStoreTransaction, where it is read. Ideally, the location where we know "we are going to create without loading" directs a path where we ensure the events get a workable AppendCondition for the tags from the published events.
One way to move the check earlier in the chain, is by adjusting the StorageEngineBackedEventStore#publish method to check for this ResourceKey. Added, we'd require a dedicated method on the EventStoreTransaction (e.g. appendCreateEvent), allowing the StorageEngineBackedEventStore to switch based on the ResourceKey. Although this improves things, we're stilling jumping from modelling-to-eventsourcing logic quite rigorously.
Another way forward might be to have a means to state "I want to publish an event with XYZ AppendCondition, right from within the entity OR entity meta-model.
Current Behaviour
We use the EntityMetamodel#CREATE_WITHOUT_LOAD resource key in the DefaultEventStoreTransaction to default the AppendCondition when tags are present.
Wanted Behaviour
There's an outward process telling the DefaultEventStoreTransaction "I want to publish creational events" or "I want to publish events with a given AppendCondition". Investigation should show which path is cleanest.
Possible Workarounds
None
Enhancement Description
Pull request #4388 introduces the
EntityMetamodel#CREATE_WITHOUT_LOADResourceKeyto differentiate inside theDefaultEventStoreTransaction. It does so to resolve #4362, which marks the scenario where an entity is created without it being loaded first. This may occur when, for example, a command does not carry a@TargetEntityIdfor a creational command handler (which is a perfectly valid scenario).Although this
ResourceKeyworks, it's quite hacky. We jump from theEntityCommandHandlingComponentinaxon-modelling, where this is set, to theDefaultEventStoreTransaction, where it is read. Ideally, the location where we know "we are going to create without loading" directs a path where we ensure the events get a workableAppendConditionfor the tags from the published events.One way to move the check earlier in the chain, is by adjusting the
StorageEngineBackedEventStore#publishmethod to check for thisResourceKey. Added, we'd require a dedicated method on theEventStoreTransaction(e.g.appendCreateEvent), allowing theStorageEngineBackedEventStoreto switch based on theResourceKey. Although this improves things, we're stilling jumping from modelling-to-eventsourcing logic quite rigorously.Another way forward might be to have a means to state "I want to publish an event with XYZ
AppendCondition, right from within the entity OR entity meta-model.Current Behaviour
We use the
EntityMetamodel#CREATE_WITHOUT_LOADresource key in theDefaultEventStoreTransactionto default theAppendConditionwhen tags are present.Wanted Behaviour
There's an outward process telling the
DefaultEventStoreTransaction"I want to publish creational events" or "I want to publish events with a givenAppendCondition". Investigation should show which path is cleanest.Possible Workarounds
None