Skip to content

Multi-Member entity event routing: docs, tests, and @EventTag recipe - #4998

Open
MateuszNaKodach wants to merge 3 commits into
mainfrom
entity-member-event-routing
Open

Multi-Member entity event routing: docs, tests, and @EventTag recipe#4998
MateuszNaKodach wants to merge 3 commits into
mainfrom
entity-member-event-routing

Conversation

@MateuszNaKodach

@MateuszNaKodach MateuszNaKodach commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Corrects the multi-entity migration guide, which wrongly claimed the Axon Framework 5 default for delivering events to child entities is equivalent to ForwardAll; it is routing-key based (only a single child without a routingKey gets every event), and a troubleshooting note now explains the two gates an event must pass: it must be sourced into the parent (every event, parent-level and child-level, must carry the parent tagKey) and then routed to the child. Extends the AddEventTagAnnotation OpenRewrite recipe to follow @AggregateMember/@EntityMember fields (including List/Map elements) and tag child events with the parent's tag, so a migrated child @EventSourcingHandler is actually sourced instead of silently skipped. Adds AxonTestFixture tests covering single and collection routing, the fail-fast on a collection without a routingKey, a broadcast matcher, the tagging/sourcing gate, UUID identifiers, and the Spring @EventSourced stereotype, plus a recipe test for the member-tagging behaviour.

The multi-entity migration guide claimed the default for delivering events to
child entities is equivalent to ForwardAll. That holds only for a single child
declared without a routingKey. With a routingKey (required for collections) the
default RoutingKeyEventTargetMatcherDefinition routes by matching the routingKey,
and a child event is silently skipped when it does not carry a matching value,
a common cause of a child @EventSourcingHandler not firing after migration.

Correct the "Event forwarding mode" section to state the actual conditional
default, and add a troubleshooting note covering the two gates an event must
pass: it must be sourced into the parent (every event, parent-level and
child-level, must carry the parent tagKey) and then routed to the child.

Add AxonTestFixture tests for the behaviour:
- EntityMemberMessageRoutingTest: single and collection routing, the fail-fast
  on a collection without a routingKey, and a broadcast matcher.
- ChildEntityEventTaggingTest: a child event only reaches the child when it
  carries the parent tag, independent of routing.
- UuidChildEntityEventSourcingTest: the same with UUID identifiers.
- SpringEventSourcedChildEntityTest: the Spring @eventsourced stereotype with a
  UUID id registers the child hierarchy and honours the tagging gate.
AddEventTagAnnotation only scanned root entity classes (@aggregate,
@eventsourced, @EventSourcedEntity), so events handled by an
@AggregateMember/@EntityMember child never received an @eventtag. After
migration those child events were not sourced into the parent stream and the
child @EventSourcingHandler never ran.

Extend the scan to collect the events used by every class and to follow
@AggregateMember/@EntityMember fields (including List and Map elements) from a
parent to its child type. Child events are reconciled into the tag targets with
the parent's identifier field name and tag key, so they are tagged with the
parent's tag and sourced into the parent stream, mirroring the single stream an
Axon Framework 4 aggregate shared with its members. The existing exact-name
match, first-field fallback, and TODO(axon4to5) comment are reused for
ambiguous cases.
@MateuszNaKodach
MateuszNaKodach requested a review from a team as a code owner September 2, 2026 08:42
@MateuszNaKodach
MateuszNaKodach requested review from hatzlj, jangalinski and zambrovski and removed request for a team September 2, 2026 08:42
@MateuszNaKodach MateuszNaKodach changed the title Child entity event routing/sourcing: docs, tests, and @EventTag recipe Multi-Entity event routing/sourcing: docs, tests, and @EventTag recipe Sep 2, 2026
@MateuszNaKodach MateuszNaKodach changed the title Multi-Entity event routing/sourcing: docs, tests, and @EventTag recipe Multi-Member entity event routing: docs, tests, and @EventTag recipe Sep 2, 2026
@MateuszNaKodach MateuszNaKodach self-assigned this Sep 2, 2026
@MateuszNaKodach MateuszNaKodach added Priority 2: Should High priority. Ideally, these issues are part of the release they’re assigned to. Type: Enhancement Use to signal an issue enhances an already existing feature of the project. labels Sep 2, 2026
@MateuszNaKodach MateuszNaKodach added this to the Release 5.4.0 milestone Sep 2, 2026
The documentation site lint (Vale rule AxonIQ.Headings, sentence-style for
h2-h6) flags the component titles of the message-handler-customization and
meta-annotations guides. Those titles render as an h3 in the navigation on
every page, so title-style capitalization fails the check and breaks the docs
build. Lowercase the non-initial words in the antora.yml titles; the page H1
titles keep title-style capitalization for the AxonIQ.HeadingTitle (h1) rule.

These were pre-existing site-wide lint errors surfaced by the shared Vale
package, unrelated to the child-entity changes, but the docs check runs on this
branch because it also touches docs, so they must be fixed for CI to pass.
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. Type: Enhancement Use to signal an issue enhances an already existing feature of the project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant