feat(migration): preserve AF4 MessageOriginProvider metadata key names in AF5#4613
Merged
Merged
Conversation
64a82ab to
75486ff
Compare
…s in AF5
AF5 renamed MessageOriginProvider's default metadata keys:
- AF4 `traceId` (propagated originating-message id) → AF5 `correlationId`
- AF4 `correlationId` (current-message id, direct cause) → AF5 `causationId`
A no-args `new MessageOriginProvider()` in AF5 silently emits metadata under
the new key names, breaking downstream consumers that still read the old keys.
Two new recipes address this:
`MigrateMessageOriginProviderDefaultKeys` (added to Axon4ToAxon5Messaging):
- Replaces every no-args `new MessageOriginProvider()` with
`new MessageOriginProvider("traceId", "correlationId")` to preserve the
AF4-compatible key names. Idempotent; explicit-arg forms are left alone.
`AddMessageOriginProviderSpringBeanConfiguration` (added to Axon4ToAxon5SpringBootExtension):
- In Spring Boot apps, creates (or updates) a `CorrelationDataProviderConfiguration`
`@Configuration` class with a `@Bean` returning the AF4-compatible provider.
- Only triggers on a no-args constructor; beans that already carry explicit
args are left completely untouched (developer's intentional choice).
- Generates the config class in the `@SpringBootApplication` root package when
the class does not yet exist; adds the `@Bean` method to an existing class.
75486ff to
1ad63f3
Compare
hatzlj
approved these changes
Jun 1, 2026
Contributor
hatzlj
left a comment
There was a problem hiding this comment.
LGTM, didn't have an example to run against but the tests validate the case sufficiently.
…ources MigrateMessageOriginProviderDefaultKeys overrode isAcceptable to gate on J.CompilationUnit, which OpenRewrite uses only for Java sources. Kotlin sources parse into K.CompilationUnit, so every .kt file was rejected before the visitor ran and no-args `MessageOriginProvider()` beans kept emitting the new AF5 metadata key names. The default JavaIsoVisitor.isAcceptable already accepts JavaSourceFile, the shared supertype of both J.CompilationUnit and K.CompilationUnit, so the override was unnecessary and actively excluded Kotlin. Removing it lets the recipe rewrite resolved Kotlin constructor calls (parsed as J.NewClass once the type is on the classpath, as in a real migration run) the same way as Java. Adds MigrateMessageOriginProviderDefaultKeysKotlinTest mirroring the Spring @bean shape, covering both the no-args rewrite and the explicit-args no-op.
|
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.




AF5 renamed MessageOriginProvider's default metadata keys:
traceId(propagated originating-message id) → AF5correlationIdcorrelationId(current-message id, direct cause) → AF5causationIdA no-args
new MessageOriginProvider()in AF5 silently emits metadata under the new key names, breaking downstream consumers that still read the old keys.Two new recipes address this:
MigrateMessageOriginProviderDefaultKeys(added to Axon4ToAxon5Messaging):new MessageOriginProvider()withnew MessageOriginProvider("traceId", "correlationId")to preserve the AF4-compatible key names. Idempotent; explicit-arg forms are left alone.AddMessageOriginProviderSpringBeanConfiguration(added to Axon4ToAxon5SpringBootExtension):CorrelationDataProviderConfiguration@Configurationclass with a@Beanreturning the AF4-compatible provider.@SpringBootApplicationroot package when the class does not yet exist; adds the @bean method to an existing class.