Skip to main content

Software Development

Introduction to CQRS, AXON Framework and AXON Server

Istock 1360521207

Introduction

We will learn about theAxon Framework,Axon Server, whatCQRSis, how it works, and why it is soPopularworldwide in this blog.

AXON is anOpen-Source Frameworkfor event-driven microservices and domain-driven design. It is aJava Frameworkthat gives developers access to repositories, implementations of crucial components including aggregates, command, and event buses, and implementations of the CQRS architectural pattern. Architecture principles likeDomain Driven DesignandCQRSare the foundation of the framework.

Additionally, we mayIntegratebusiness logic across numerous distributed微Servicesusing the AXON framework, while also building incrediblyScalableandFlexible Applications.

Due to its excellentInteractionwithSpring BootandSpring Framework,它有一个显著的好处。因此,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, orCommand 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 intoTwo Categories:

  1. Commands
  2. Query

Picture17

AClient Applicationwill make anHTTP Requestwhenever it interacts with our micro service.POST, PUT, DELETE, or PATCHare a few examples. A HTTPGETrequest can also be sent by it.

These requests can be viewed as commands that carry out specific tasks. Additionally, sinceGETRequest asks our microservices to return some data, we may consider it to be aQuery.

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

Think of aQueryas a request for information when developing a new product, for instance. such asfindProductById.

The operations and query aggregation in theImageare carried out by a single microservice. We have aSingle Microservicethat 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 thegetUserorfindProductqueries. 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 likeDomain Driven Design, CQRSandEvent Driven Architectureare 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.

Picture18

The major events will be persistent in theEvent 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

不仅仅是框架,轴突。这Architectureincludes AXON Server as well.

Axon provides aQuick Start Toolkitso that you are familiar with the configuration required for Axon Framework and Axon Server SE (Standard Edition).

Picture19

The onlyPrerequisitefor 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.

Picture20

You may search anEvent Storeon 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.

Congratulations

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

Happy Coding

Happy coding!

Leave a Reply

Your email address will not be published.Required fields are marked*

这site uses Akismet to reduce spam.Learn how your comment data is processed.

Sanket Dudhe

Sanket Dudhe is an Associate Technical Consultant at Perficient. He has an experience of 3+ years in Development. He loves technology and hence is curious to learn about new emerging technologies #lovefortechnology.

More from this Author

Follow Us
Twitter Linkedin Facebook Youtube Instagram