Skip to content

Adjust EntityMetamodel#CREATE_WITHOUT_LOAD usage #4588

Description

@smcvb

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority 2: ShouldHigh priority. Ideally, these issues are part of the release they’re assigned to.

    Fields

    No fields configured for Enhancement.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions