Upgrading to Axon Framework 4.7 - Automated
Automation through OpenRewrite
In a previous blog, we explained our discontent and reasoning behind the introduction of breaking changes in Axon Framework 4.7.
Our desire to support Spring Boot 3 and Spring Framework 6 required us to deal with the hard shift from Javax to Jakarta by introducing dedicated legacy packages for the former (Javax), making the latter (Jakarta) the default. We are confident that, although it requires some work when upgrading, this shift improves the overall stability of the project.
As part of the effort to switch from Javax to Jakarta, the Framework team discussed whether we should provide OpenRewrite scripts. For those unaware: OpenRewrite is a library dedicated to "mass source code refactoring," thus simplifying the task of resolving breaking changes. For example, you can find OpenRewrite recipes for migrating to Java 17 and Spring Boot 3. Therefore, we deemed it an ideal candidate to ease migration to Axon Framework 4.7.
We agreed that OpenRewrite is a valuable topic to research, but we did not have sufficient resources to work on this ASAP. Instead, we've put it on our backlog to delve into once Axon Framework 5 comes into play.
Axon Migration Module
Soon after this discussion, we proved to be lucky. We received an issue and pull request from Tim te Beek to provide OpenRewrite recipes for Axon Framework 4.7! Hence, as of release 4.7.2 of Axon Framework, there's a new module present: `axon-migration`.
This module contains two recipes based on the verbal explanation in the previous blog:
Upgrade to Axon Framework 4.7 Jakarta - A recipe to upgrade from an Axon Framework Javax-specific project to Jakarta.
Upgrade to Axon Framework 4.7 Javax - A recipe to upgrade an Axon Framework Javax-specific project and remain on Javax.
As shown in the readme of the axon-migration module, all you'd have to do to migrate to 4.7 and stick with Javax is:
mvn -U org.openrewrite.maven:rewrite-maven-plugin:4.40.0:run \
-Drewrite.recipeArtifactCoordinates=org.axonframework:axon-migration:LATEST \
-DactiveRecipes=org.axonframework.migration.UpgradeAxonFramework_4_7_Javax
Although the above sample uses Maven, you can, of course, use Gradle just as well. To that end, we recommend you check out the following documentation from OpenRewrite.
Instead of sticking to Javax with Axon Framework 4.7, you can also combine a migration to Java 17, Spring Boot 3, and Axon Framework 4.7 Jakarta in one go:
mvn -U org.openrewrite.maven:rewrite-maven-plugin:4.40.0:run \
-Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:4.33.0,org.axonframework:axon-migration:LATEST \
-DactiveRecipes=org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_0,org.axonframework.migration.UpgradeAxonFramework_4_7_Jakarta
Conclusion
With the introduction of OpenRewrite, we believe migrating to Axon Framework 4.7 is made more straightforward. Furthermore, we will add or update the scripts accordingly for future breaking changes, especially for Axon Framework 5.
If you try the recipes, but something's amiss, be sure to reach out! We gladly receive feedback on AxonIQ's forum. Similarly, if the predicament is OpenRewrite-specific, they'll surely help you out.

Steven van Beelen
Steven is a lead developer at AxonIQ with a keen interest in new and exciting technologies and methodologies.
Furthermore, he's a developer passionate about helping others make awesome software.
This has led him to embrace the open-source mindset, become a trainer, a speaker, and provide guidance on various Q&A fora.
He focuses on concepts like DDD, CQRS, and Event Sourcing, as he sees those as great enablers for well-structured, modular applications.
Most of his time is spent developing Axon Framework at AxonIQ to enhance the support of these concepts.
When he's not writing code or helping others, he's likely busy with music, video games, or real-life construction work.

September 28th, Amsterdam
Join us for the AxonIQ Conference 2023, where the developer community attends to get inspired by curated talks and networking.

September 27th, Amsterdam
The event to collaborate, discuss, and share knowledge about techniques, tools, and practices for building complex, distributed event-driven applications.
AxonIQ © 2022 | Privacy Policy | Cookies