Skip to content

feat(migration): preserve AF4 MessageOriginProvider metadata key names in AF5#4613

Merged
MateuszNaKodach merged 2 commits into
axon-5.1.xfrom
feat/5.1-openrewrite-messageorigin
Jun 1, 2026
Merged

feat(migration): preserve AF4 MessageOriginProvider metadata key names in AF5#4613
MateuszNaKodach merged 2 commits into
axon-5.1.xfrom
feat/5.1-openrewrite-messageorigin

Conversation

@MateuszNaKodach
Copy link
Copy Markdown
Contributor

@MateuszNaKodach MateuszNaKodach commented May 25, 2026

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.

@MateuszNaKodach MateuszNaKodach requested a review from a team as a code owner May 25, 2026 08:54
@MateuszNaKodach MateuszNaKodach requested review from jangalinski, smcvb and zambrovski and removed request for a team May 25, 2026 08:54
@MateuszNaKodach MateuszNaKodach self-assigned this May 25, 2026
@MateuszNaKodach MateuszNaKodach added Type: Feature Use to signal an issue is completely new to the project. Priority 2: Should High priority. Ideally, these issues are part of the release they’re assigned to. labels May 25, 2026
@MateuszNaKodach MateuszNaKodach added this to the Release 5.1.2 milestone May 25, 2026
@MateuszNaKodach MateuszNaKodach force-pushed the feat/5.1-openrewrite-messageorigin branch from 64a82ab to 75486ff Compare May 25, 2026 08:55
…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.
@MateuszNaKodach MateuszNaKodach force-pushed the feat/5.1-openrewrite-messageorigin branch from 75486ff to 1ad63f3 Compare May 25, 2026 08:55
Copy link
Copy Markdown
Contributor

@hatzlj hatzlj left a comment

Choose a reason for hiding this comment

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

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.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 1, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@MateuszNaKodach MateuszNaKodach merged commit 100b282 into axon-5.1.x Jun 1, 2026
7 of 8 checks passed
@MateuszNaKodach MateuszNaKodach deleted the feat/5.1-openrewrite-messageorigin branch June 1, 2026 12:06
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: Feature Use to signal an issue is completely new to the project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants