Migrate routingKey to @Command annotations #4704
Open
klauss42 wants to merge 2 commits into
Open
Conversation
abuijze
reviewed
Jul 3, 2026
abuijze
left a comment
Contributor
There was a problem hiding this comment.
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}, |
Contributor
There was a problem hiding this comment.
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.
Author
There was a problem hiding this comment.
I added the check for existing @routingkey annotation to take precedence
…TargetAggregateIdentifier or @TargetEntityId
routingKey to @Command annotations
Author
|
CLA signed. Sorry, I'm not used to all this GH/PR handling. Working trunk-based since years :-) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Solves #4701