A Brief Introduction to Axon Framework

Reading Time: 3 minutes

Need for Axon Framework

Axon Framework is designed to support developers in applying the CQRS/DDD architectural pattern and Event Sourcing. It helps developers build easily scalable and maintainable applications by providing implementations of some basic building blocks, such as Aggregates, repositories, and event buses 

Axon Framework, founded by Allard Buijze also working for Trifork, is an open source product with version 3 planned for Q1 2016.

CQRS Example Using Axon Framework

CQRS) is a way of building software systems that separate the part that changes the state from the part that queries the state. Axon Framework is a Java framework that provides implementations of the most important building blocks, e.g. aggregates, command, and event buses, as well as repositories to help developers apply the CQRS architectural pattern when building applications.

CQRS includes:

  • Commands, that capture the intent of what needs to happen. In Axon, they are POJOs not required to implement any interface.
  • Command handlers, acting on the commands sent. In Axon, they can be created either by implementing an interface or annotation.
  • Command bus, that routes command to their respective command handlers. Axon comes with four implementations of which Aderemi uses a simple synchronous bus for dispatching commands. 

On the Query side it includes:

  • Domain events represent something that has happened in the past and are created by changes in state in the domain, changes initiated by commands and their handlers.
  • Event Bus, transporting the events to the query side. Axon comes with a few implementations of which Aderemi uses a simple implementation.
  • Event Handlers listen to events and use the information to maintain a reflection of the state of the application on the query side. In Axon, they are defined using an annotation.

Dealing with the Complexity

Axon originated in an attempt to find a solution to the ever-increasing accidental complexity. Applying concepts from Domain-Driven Design will help to a very large degree, even the most well-designed model will not run by itself in production.

While Axon is opinionated on how the interaction with a domain model should take place, it tries to avoid any restrictions on the modeling freedom that one has. Even when your opinion differs from that of Axon, there are enough hooks, configuration options, and triggers to change certain aspects of Axon’s behavior. You will find those throughout the reference guide.

Axon Framework in microservices

Axon Framework is a Java microservices framework that helps you build microservices architecture in-line with Domain Driven Design (DDD) principles. Apart from DDD, Axon Framework also allows you to implement microservices patterns such as Command-Query-Responsibility-Segregation (CQRS) and Event-Driven Architecture.

Axon Server

Axon Server contains a storage engine that is designed for the specific purpose of storing events for event sourcing. It offers superior scalability and throughput characteristics without requiring difficult tuning.


Axon has a Quickstart toolkit to set up the Axon framework and Axon server

Requires Java 8+ JRE in your system.

Can be downloaded from here: https://axoniq.io/download

Running the Axon Server

After Downloading, follow the steps below to run it:

1. $ java -jar AxonServer/axonserver-VERSION.jar
2. View the Axon Server web dashboard here: http://localhost:8024/
3. Run the demo application:
   $ cd giftcard-demo && ./mvnw spring-boot:run
4. Open the Demo application here: http://localhost:8080/

Relation between Kafka and Axon

Axon provides an extension dedicated to publishing and receiving event messages from Kafka. The Kafka Extension should be regarded as an alternative approach to distributing events, besides (the default) Axon Server.

Advantages of Axon

  1. Unified Distributed Messaging Solution: Arguably one of the main reasons AxonIQ started in the first place. Sending commands, events, and queries in a single application is straightforward with the provided message buses.
  2. Event Processing Enhancements: Updating your views and search capabilities based on the latest events flowing through your system becomes a fact of life when using Axon.
  3. Real-time Event Streaming: Although the Tracking Event Processor is pretty neat, there was still one performance impact that could be tackled.
  4. Aggregate Modeling Improvements: We all know that Axon provides a great stepping stone to DDD.
  5. Multi-Context Support: When doing DDD, the notion of Bounded Contexts will definitely cross your path.


In this blog we learned about the basics of the Axon framework, the need for axons, took a CQRS application example, and got to know how Axon is working with microservices and a quick start on how can we run axon server in our system. We will be covering this in more depth in our upcoming blogs
Till then Happy learning, happy sharing!!

For more information related to Axon, you can follow these easygoing links as well: https://blog.knoldus.com/axon-part-1-an-introduction-to-axon-framework/