New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#2689] Support Snapshotting for Polymorphic Aggregates #2753
Merged
smcvb
merged 7 commits into
master
from
feature/2689-polymorphic-aggregate-snapshot-support
Jun 16, 2023
Merged
[#2689] Support Snapshotting for Polymorphic Aggregates #2753
smcvb
merged 7 commits into
master
from
feature/2689-polymorphic-aggregate-snapshot-support
Jun 16, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add test cases for polymorphic aggregate snapshotting, both during aggregate construction and subsequent command handling. The former inserts the aggregate type based on the model, whereas the latter retrieves the type from a domain event. Due to this, the paths are slightly different. #2689
Whenever we're dealing with a polymorphic aggregate, the provided prototypeBeanName can not reference any existing bean. This stems from the point that root aggregate types are intended to be abstract, causing them not to end up in the Application Context. Due to this, polymorphic aggregate snapshotting currently defaults to the first concrete class, resulting in incorrect aggregate types in the snapshot events. Furthermore, it causes snapshot creation during aggregate creation to simply not work. #2689
The approach towards defining the root/top aggregate name should change to accommodate for the fact an abstract @aggregate annotated root class does not occur in the ApplicationContext. Due to this, the aggregate hierarchy is essentially wrong. We should instead default to a reasonable root aggregate bean name for our own purposes, and provide this name to the SpringPrototypeAggregateFactory #2689
smcvb
added
Type: Feature
Use to signal an issue is completely new to the project.
Priority 2: Should
High priority. Ideally, these issues are part of the release they’re assigned to.
Status: In Progress
Use to signal this issue is actively worked on.
labels
Jun 15, 2023
smcvb
requested review from
gklijs and
CodeDrivenMitch
and removed request for
a team
June 15, 2023 15:34
Drop subtype prototype bean validation, as there's no guarantee all subtypes are annotated with @aggregate. Users are only inclined to mark the root and children of a polymorphic aggregate, so nodes in the middle are by nature not prototype beans. Furthermore, open post-processing a bean name for the root type should be returned too. To that end we need to check whether the provided aggregate (to post-process) equals the configured aggregateType. When true, we return the prototypeBeanName. When false, the type should by a subtype by definition. #2689
Although the chances are extremely slim users are working with the deprecated SpringAxonAutoConfigurer directly, it should support the adjusted factory construction regardless. #2689
The SpringPrototypeAggregateFactoryTest deserves an update, as it is based on old ideas of aggregate prototype bean wiring (with a xml file, for example). Adjust it so that it mirrors how Axon's Spring Boot autoconfiguration works, without relying on Spring Boot. #2689
Kudos, SonarCloud Quality Gate passed! |
Clean test case by using isTrue/isFalse i.o. isEqualTo(true)/isEqualTo (false) #2680
CodeDrivenMitch
approved these changes
Jun 16, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
smcvb
added
Status: Resolved
Use to signal that work on this issue is done.
and removed
Status: In Progress
Use to signal this issue is actively worked on.
labels
Jun 16, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Priority 2: Should
High priority. Ideally, these issues are part of the release they’re assigned to.
Status: Resolved
Use to signal that work on this issue is done.
Type: Feature
Use to signal an issue is completely new to the project.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adjust the
SpringPrototypeAggregateFactory
to expect a fixedaggregateType
instead of retrieving it from theApplicationContext
.This is necessary as
abstract
classes, as we recommend for the root of a polymorphic aggregate, and due to this, they are simply not a part of theApplicationContext
.This causes the returned type from
AggregateFactory#getAggregateType
to be faulty for polymorphic aggregates.The only spot where this hurts is during snapshot creation; hence meriting this fix.
Combined with the
SpringPrototypeAggregateFactory
, we need to ensure theSpringAggregateLookup
correctly constructs said instance without dropping the root type name.In doing the above, this pull request resolves #2689.