Introduction

We will learn about the Axon Framework, Axon Server, what CQRS is, how it works, and why it is so Popular worldwide in this blog.

AXON is an Open-Source Framework for event-driven microservices and domain-driven design. It is a Java Framework that gives developers access to repositories, implementations of crucial components including aggregates, command, and event buses, and implementations of the CQRS architectural pattern. Architecture principles like Domain Driven Design and CQRS are the foundation of the framework.

Additionally, we may Integrate business logic across numerous distributed Micro Services using the AXON framework, while also building incredibly Scalable and Flexible Applications.

Due to its excellent Interaction with Spring Boot and Spring Framework, it has a significant benefit. And as a result, the framework will handle a lot of the setups, allowing us to concentrate just on developing the business logic.

Let’s first understand the CQRS design pattern before using the Axum framework. We’ll continue learning about the Axon framework and observe how CQRS applications are created using this framework.

 

CQRS

CQRS, or Command Query Responsibility Segregation, is the acronym for this technique. The name Command Query Responsibility Segregation because The CQRS design pattern divides your application’s components’ responsibilities primarily into Two Categories:

Commands
Query

 

 

A Client Application will make an HTTP Request whenever it interacts with our micro service. POST, PUT, DELETE, or PATCH are a few examples. A HTTP GET request can also be sent by it.

These requests can be viewed as commands that carry out specific tasks. Additionally, since GET Request asks our microservices to return some data, we may consider it to be a Query.

The microservices will get a fresh Command each time we want them to carry out a certain Operation. And we’ll use a Query API when a microservice needs to Retrieve some data from a database. Consider a command as the desire to cause an action.

Think of a Query as a request for information when developing a new product, for instance. such as findProductById.

The operations and query aggregation in the Image are carried out by a single microservice. We have a Single Microservice that can be split into queries and instructions, as necessary.

We can divide this microservice into two other microservices when scaling up. Commands will be handled by one microservice, and inquiries by another microservice.

Type of message:

Command:

Intent to change the state of application.

Ex. CreateProductCommand, UpdateProductCommand, DeleteProductCommand.

State and example of command message will be Create message command or Update message command or Delete message command because a command is an intent to make a change. It’s usually named in the imperative tense.

Query:

When generating queries, which are typically given a fine or a Get prefix, the intent is to indicate a need for information. such like the getUser or findProduct queries. The message type is an event that signifies that something has occurred. For instance, the application will publish a product produced event when a new product is created. Our application will publish an event with the name “product updated event” if the product details are modified.

 

Axon Framework

Architectural tenets like Domain Driven Design, CQRS and Event Driven Architecture are the foundation of the Axon Framework. And on this figure, you can see how all these principles are put into practise. Command and query are the two key sections of our application.

The major events will be persistent in the Event Store, and it makes advantage of event sourcing. For other components that are interested in this event to consume and act on it, the Command API will also publish an event that was persisted in the events database.

An event handler, which is on the query side, will be one of the components. The query database will be updated with the new data once it consumes an event.

Axon now provides us the opportunity to configure where to store our events and data when it comes to storage.

For instance, we can choose to store our events in the conventional rational database management system, such as PostgreSQL or MySQL, or we can utilize the event store that is offered to us by the Axon framework.

 

AXON Server

Not merely the framework, AXON is more. This Architecture includes AXON Server as well.

Axon provides a Quick Start Toolkit so that you are familiar with the configuration required for Axon Framework and Axon Server SE (Standard Edition).

The only Prerequisite for using the Quick Start is that Java 8+ JRE must be installed on your computer.

AXON Server manages all the event store, and it even comes in two Edition.

Standard Edition
Enterprise Edition

They can run in clusters and can be scaled across multiple geographical regions.

With your username and password, you may access the protected dashboard on the AXON Server to examine a list of all the applications that are currently executing as well as their status and other important information.

You may search an Event Store on AXON Server and even watch live updates as events are added to the shop.

You can preview the details of each event that occurred and was recorded in the events store as well as search the events store using specialized query language.

Conclusion: We learnt about the Axon Framework, Axon Server, What Command Query Responsibility Segregation is.

Happy coding!