Axon Framework provides the building blocks that CQRS requires and helps developers to create scalable and extensible applications while maintaining application consistency in distributed systems. It helps by handling the communication of messages, such as commands, events, and queries.
However, your IDE does not understand this, and so it will leave finding message handlers or publishers up to your memory. We are introducing the IntelliJ Axon Framework plugin to solve this problem. You can download it via the Jetbrains marketplace within IntelliJ or the marketplace website.
You often want to navigate between producers of a message and handlers of that message. The IntelliJ plugin creates line markers at these locations, containing the references to their counterpart. Clicking on the line marker will reveal the options.
Methods annotated with a handler annotation, such as CommandHandlers, will get a line marker to navigate to constructor invocations of that payload. The text describing an option will help you, showing which handler is producing this message. For example, if a @SagaEventHandler publishes the command, that saga will be shown as the publisher of that command. If there are no parent handlers, it will show the method’s name instead. This method can be part of a Spring bean, a controller, or any other class. In the following example, we can see that both a saga and a Spring Controller produce a command.
The plugin will also show handlers when creating a message. The IntelliJ plugin will display a line marker at the locations you instantiate a class if that class is known as a message. The plugin understands inheritance and will show more generic handlers as well. In the following example, we can see a line marker on a constructor invocation of a message that is handled in four different places throughout the application. Of these options, three are projections, and one is the EventSourcingHandler for this aggregate.
When the plugin recognizes a class as a message, it shows a line marker at the class declaration that contains both the handlers and constructor invocations. Here, we can see that the command is published by a saga and some controllers. We can also see that the command is handled in the Room aggregate.
Last but not least, it can sometimes be hard to find related aggregate members or the parent aggregate of an entity. The plugin shows a line marker on all aggregates and entities with related classes. For example, if Booking is an @AggregateMember of Room, a line marker is shown to navigate easily.
These navigational features will undoubtedly improve your productivity with Axon Framework and help new people to understand the framework more easily.
Axon Framework has specific requirements when working with aggregates or entities. These can be easy to miss for new users of the framework.
The plugin adds inspections to highlight these errors to users. One of these scenarios is when a developer forgets to add an empty constructor to the aggregate. The class definition will show a warning that it’s missing while required by Axon Framework.
Other inspections are also in place. For example, an error is shown when entities have no @EntityId annotation or an aggregate has no @AggregateIdentifier annotation.
The plugin is designed to make working with Axon Framework in your favorite IDE much easier. We at AxonIQ will continue to support and expand the plugin to make usage of the Axon Framework as easy as possible!
We would love for you to report any features you’d like to see at our Github issue tracker. We are always happy to receive feedback and hope this plugin is just what you were looking for!
Mitchell Herrijgers is a Solution Engineer at AxonIQ, helping customers build their applications based on Axon in a good manner. He has a passion for developing developer tooling and making the lives of other developers easier.