DDD. Event sourcing. CQRS. REST. Modular. Microservices. Kotlin. Spring. Axon platform. Apache Kafka. RabbitMQ
This is a thin layer which coordinates the application activity. It does not contain business logic. It does not hold the state of the business objects
We designed and structured our loosely coupled components in a modular way, and that enable us to choose different deployment strategy and take first step towards Microservices architectural style.
Each microservice:
events
, commands
, queries
) between them via AxonServerThis a second version (2.2) of the REST Microservices application
in which we use AxonServer as an infrastructural component.
Both AxonFramework and AxonServer form an Axon platform.
The key characteristics of AxonServer are:
commands
, events
, queries
) in a message-driven micro-services environmentAxonServer connector is configured by default (included in axon-spring-boot-starter
) :
<dependency>
<groupId>org.axonframework</groupId>
<artifactId>axon-spring-boot-starter</artifactId>
<version>${axon.version}</version>
</dependency>
Alternatively, you can exclude AxonServer connector and fallback to JPA event store and storage in general.
In that case you have to choose (and configure, and operate) Spring Cloud to distribute commands
, and Kafka or RabbitMQ to distribute events
.
<dependency>
<groupId>org.axonframework</groupId>
<artifactId>axon-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.axonframework</groupId>
<artifactId>axon-server-connector</artifactId>
</exclusion>
</exclusions>
</dependency>
We did this already in the first version of ‘REST Microservices application’ as a proof that you can benefit from AxonFramework programming model only (without AxonServer as an infrastructural component). first version is using:
command
and query
side component included -> there is no independent query
microservice -> you can not scale goodAxonFramework programing model is recognizing three categories of messages at the moment:
and they require different mechanisms of routing and distributing. AxonServer is built with this in mind, and you should consider it as an important tactical asset in you architecture. This will enable you to focus on your domain model and strategic design.
AxonFramework and AxonServer are open source
. Axon Server Enterprise is targeted towards mission-critical, medium to large scale production deployments of Axon.
curl http://localhost:8085/restaurants
curl -i -X POST --header 'Content-Type: application/json' --header 'Accept: */*' -d '{
"menuItems": [
{
"id": "id1",
"name": "name1",
"price": 100
}
],
"name": "Fancy"
}' 'http://localhost:8084/restaurants'
curl -i -X PUT --header 'Content-Type: application/json' --header 'Accept: */*' 'http://localhost:8084/restaurants/RESTAURANT_ID/orders/RESTAURANT_ORDER_ID/markprepared'
curl http://localhost:8085/customers
curl -i -X POST --header 'Content-Type: application/json' --header 'Accept: */*' -d '{
"firstName": "Ivan",
"lastName": "Dugalic",
"orderLimit": 1000
}' 'http://localhost:8082/customers'
curl http://localhost:8085/couriers
curl -i -X POST --header 'Content-Type: application/json' --header 'Accept: */*' -d '{
"firstName": "John",
"lastName": "Doe",
"maxNumberOfActiveOrders": 20
}' 'http://localhost:8081/couriers'
curl -i -X PUT --header 'Content-Type: application/json' --header 'Accept: */*' 'http://localhost:8081/couriers/COURIER_ID/orders/COURIER_ORDER_ID/assign'
curl -i -X PUT --header 'Content-Type: application/json' --header 'Accept: */*' 'http://localhost:8081/couriers/COURIER_ID/orders/COURIER_ORDER_ID/markdelivered'
curl http://localhost:8085/orders
curl -i -X POST --header 'Content-Type: application/json' --header 'Accept: */*' -d '{
"customerId": "CUSTOMER_ID",
"orderItems": [
{
"id": "id1",
"name": "name1",
"price": 100,
"quantity": 0
}
],
"restaurantId": "RESTAURANT_ID"
}' 'http://localhost:8083/orders'
Note: Replace CUSTOMER_ID and RESTAURANT_ID with concrete values.
This project is driven using Maven.
$ git clone https://github.com/idugalic/digital-restaurant
$ cd digital-restaurant
$ mvn clean install
NOTE: AxonServer is required.
$ cd digital-restaurant/drestaurant-apps/drestaurant-microservices-rest/drestaurant-microservices-rest-2-query
$ mvn spring-boot:run
$ cd digital-restaurant/drestaurant-apps/drestaurant-microservices-rest/drestaurant-microservices-rest-2-command-courier
$ mvn spring-boot:run
$ cd digital-restaurant/drestaurant-apps/drestaurant-microservices-rest/drestaurant-microservices-rest-2-command-customer
$ mvn spring-boot:run
$ cd digital-restaurant/drestaurant-apps/drestaurant-microservices-rest/drestaurant-microservices-rest-2-command-restaurant
$ mvn spring-boot:run
$ cd digital-restaurant/drestaurant-apps/drestaurant-microservices-rest/drestaurant-microservices-rest-2-command-order
$ mvn spring-boot:run