Axon – The Best Platform for Microservices

In this article, I would tell you about the Axon Platform. From my view so far, it is the best for building robust microservices.

The Axon Platform consists of The Axon Framework and the Axon Server.

These products are developed and maintained by AxonIQ, a software company founded in 2017 based in The Netherlands.

The Axon Framework provides you with a neat and elegant Java API for building CQRS, DDD and Event Sourcing application.

The Axon Server provides functionality for event store and message routing with minimal configuration. Also, the Axon Server come in two editions:

  • The Axon Standard Server: This edition is free and can be used for small applications.
  • The Axon Enterprise Server: Provides additional features including clustering and multi-context support. Can be used for larger production deployment of mission-critical application.

 

Axon Architectural Concepts

Axon is based on the following three architectural concepts:

 

1. Domain-Driven Design (DDD)

This is a design pattern that focuses on designing a software in line with the business requirements. It is based on business domain model instead of specific technology considerations. The Axon framework conforms to this by separating the domain logic from the infrastructural concern. Therefore complexity is reduced to minimum.

 

2. Event Sourcing(ES)

Event Sourcing is a pattern of data persistence such that all state changes  of an entity is stored, not just the current state. Axon Framework provides API for implementation of Event Sourcing with minimal boiler-plate coding.

 

3. Command Query Responsibility Segregation (CQRS)

CQRS is an architectural pattern the recommends splitting the application such that the command component is isolated from the query component. The Axon Platform provides the required building blocks to create this separation. It also makes it easy for you to build the components and relay messages (commands, queries and events) to the appropriate target within the application.

 

4. Microservices

As you know, the microservices architectural style of provides a way of splitting application into services that are independently deployable. The Axon platform reduces the effort and time needed to build  and deploy microservices.

 

 

Axon Core Principles

Axon highlights the following three as its core design principles

 

1. Separation of Business from Infrastructure

As mentioned before, this implies a separation of business logic from infrastructural concerns. This allows for code maintainability in the long term. In Axon, the business logic is implemented in classes which in turn connect with different message buses.

Some of the elements provided by Axon for implementing the business logic includes:

  • Aggregates:
  • Command Handlers
  • Event Handlers
  • View Models
  • Sagas

 

2. Communication Through Messages

Since the components of the microservices architecture are loosely couples, the key means of communication is via messages. This allows the services to interact with each other without having to know the internal details of the services. Also the benefit to developers is that while they develop actions to be taken in response to a message, they don’t need to worry about how the message was emitted.

In Axon, there are three categories of messages:

Commands: represents an intent to perform a state-changing operation. For example CreateOrderCommand

Events: represents a notification that an action has occurred. For example OrderCreatedEvent

Queries: represents a request for information

 

3. Location Transparency

This principle means that the interacting components need not know where the other components resides. According to Axon, Location Trransparency allows the information system to evolve from a structured monolithic system to a full-fledged microservices system.