Comments (6)
Thanks for filing this concern with us, @stephan-strate.
I'll take a look at what is amiss with the AggregateTestFixture
.
I may come with follow-up questions later on, so stay tuned!
from axonframework.
Ah, alright, I am pretty sure I have found the predicament. Luckily, it's straightforward.
The reason the FixtureTest_Hierarchy
test fails if you move the @CommandHandler
annotated method to the concrete aggregate i.o. the abstract aggregate, is because the AggregateTestFixture
is constructed based on the AbstractAggregate
.
If you base the AggregateTestFixture
on the ConcreteAggregate
instead, the test succeeds as expected.
Furthermore, doing so aligns with Axon Framework's wiring logic.
If you configure aggregate through the AggregateConfigurer
, you're also required to provide the concrete type, not any of the abstract classes.
In a Spring environment, the scenario would be the same, although Axon Framework will look up the concrete type(s) for you, based on the @Aggregate
annotation.
With that, I am pretty comfortable with closing this issue as resolved.
If I have missed anything obvious or you still have questions, @stephan-strate, be sure to reach out!
from axonframework.
Sure, this works. But it seems like the fixture should be able to find all @CommandHandler
when configuring it like this:
val fixture = AggregateTestFixture(AbstractAggregate::class.java)
.withSubtypes(ConcreteAggregateA::class.java, ConcreteAggregateB::class.java)
.registerAggregateFactory(object : AggregateFactory<AbstractAggregate> {
// resolve aggregate type by event
})
from axonframework.
Can you explain why do you think the fixture should be able to deal with ingestion of the abstract type instead of the concrete type, @stephan-strate?
Is that because the code is as it is right now?
Or do you feel the JavaDoc is lacking?
As stated above, Axon Framework production code does not use the abstract type for aggregate registration. Ever.
As such, the fixture should neither. Instead, it should follow the approach taken in production to register an aggregate.
Hence why I am asking why you feel differently. Perhaps I am missing something obvious here.
from axonframework.
Hmm, maybe I am mistaken. Sure in production it might have the concrete type. In test it does as well, resolved by the AggregateFactory
.
I mean in production I do register the abstract aggregate with it subtypes as well, right?
from axonframework.
Ah, gotcha! There is a slight, but conceptual difference between the FixtureTest_Hierarchy
and the Polymorphic Aggregate support.
The FixtureTest_Hierarchy
was constructed as part of supporting hierarchical aggregates (somewhere in 2015) with just one concrete type.
With this feature introduction, the AggregateTestFixture
didn't have to alter nor did the Framework impose any constraints on how the parent and concrete types look.
Polymorphic aggregates where introduced more recent (2019 if I recall correctly), which did imply API changes for the user.
For one, when registering an aggregate, you are inclined to provide both the root type as well as the concrete types.
For the AggregateConfigurer
and AggregateTestFixture
that's the withSubtypes(Class...)
method, for example.
In a Spring environment, users are inclined to add the @Aggregate
annotation to the root and the children (so that Axon Framework can find the whole "tree").
Furthermore, and more importantly for the FixtureTest_Hierarchy
test case, is that a polymorphic aggregate is not allowed to have a constructor on the root.
However, the FixtureTest_Hierarchy.AbstractAggregate
has a constructor, whereas the FixtureTest_Hierarchy.ConcreteAggregate
does not.
As such, it does not comply with the required polymorphic-aggregate format, but with the "old-fashioned" hierarchical aggregate format.
If you adjust the FixtureTest_Hierarchy
by using the withSubtypes
method, remove the AbstractAggregate
constructor, and by adding a command handling constructor to the ConcreteAggregate
, the test succeeds.
I hope all the above explains the current setup, @stephan-strate!
And one question remains: do you think we need to adjust documentation/javadoc somewhere to make this more apparent?
from axonframework.
Related Issues (20)
- Add create/delete context operations to the `AxonServerContainer`
- Subscription Query Update Events are dropped when using AxonServer if the events are created with List.of or stream.toList(). HOT 5
- Aggregate snapshotter stops working HOT 1
- Gaps in the GapAwareTackingTokens are not cleaned up in the TokeStore after the specified gapTimeout. HOT 5
- Except-Logic for DisallowReplay annotation HOT 3
- Allow easy configuration of CBOR
- Improve Spanfactory configurability HOT 7
- Eventual Consistency Question - Doesn't work correctly to get the result of the saga process, from the EventStore using method readEvents HOT 1
- Allow configuration of a processing group's type through the annotation. HOT 4
- Enhancing metric observability HOT 1
- Claim segments operation for Streaming Event Processors
- Log notification about AxonIQ console, if console-framework-client is not there
- axon-tracing-opentelemetry with Spring Devtools crashes on start HOT 2
- AxonDbSchedulerAutoConfiguration can not be used multiple times in hierarchical Spring context due to static fields HOT 15
- Shutdown-Mechanism of DbSchedulerDeadlineManager HOT 12
- InfraConfiguration.springAxonConfigurer ignores ConfigurerModule.order() HOT 5
- TrackingEventProcessor does not start all threads in rare cases HOT 2
- ComponentLocator does not resolve beans from Spring Parent Context HOT 6
- Various issues when importing Axon in Eclipse HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from axonframework.