Skip to content

Migrate routingKey to @Command annotations #4704

Open
klauss42 wants to merge 2 commits into
AxonIQ:mainfrom
klauss42:feat/migration-routingKey
Open

Migrate routingKey to @Command annotations #4704
klauss42 wants to merge 2 commits into
AxonIQ:mainfrom
klauss42:feat/migration-routingKey

Conversation

@klauss42

@klauss42 klauss42 commented Jul 3, 2026

Copy link
Copy Markdown

Solves #4701

@klauss42 klauss42 requested a review from a team as a code owner July 3, 2026 08:35
@klauss42 klauss42 requested review from MateuszNaKodach, jangalinski and zambrovski and removed request for a team July 3, 2026 08:36
@CLAassistant

CLAassistant commented Jul 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@abuijze abuijze left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good. It does surface one minor issue, though. It may accidentally choose the wrong field when both the RoutingKey and TargetAggregateIdentifier annotations are present on a message.

* Returns the name of the first field / record component that carries an AF4 or AF5
* {@code @RoutingKey} annotation, walking both the primary-constructor record components and
* the class body. Returns {@code null} if no such field exists.
* Returns the name of the first field / record component that carries an {@code @RoutingKey},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking, we should give @RoutingKey annotated fields precedence over @TargetAggregateIdentifier.

In this example:

public record ReassignCommand(
    @TargetEntityId String orderId,   // declared first → picked
    @RoutingKey     String shardKey   // AF4 would have routed on THIS
) {}

the orderId field would be picked, while Axon 4 would have used shardKey as the routing key.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the check for existing @routingkey annotation to take precedence

@hatzlj hatzlj added Type: Enhancement Use to signal an issue enhances an already existing feature of the project. Priority 2: Should High priority. Ideally, these issues are part of the release they’re assigned to. labels Jul 6, 2026
@hatzlj hatzlj added this to the Release 5.2.0 milestone Jul 6, 2026
…TargetAggregateIdentifier or @TargetEntityId

@smcvb smcvb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me, thanks for the PR, @klauss42!
I do have a last question for you though. Could you sign the CLA?
Otherwise we will not be able to accept this pull request.

@smcvb smcvb changed the title feature(migration): migrate routingKey for @Command's Migrate routingKey to @Command annotations Jul 8, 2026
@klauss42

klauss42 commented Jul 8, 2026

Copy link
Copy Markdown
Author

CLA signed. Sorry, I'm not used to all this GH/PR handling. Working trunk-based since years :-)

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.

5 participants