artshishkin / art-kargopolov-cqrs-saga-axon-microservices Goto Github PK
View Code? Open in Web Editor NEWTutorial - Spring Boot Microservices, CQRS, SAGA, Axon Framework - from Sergey Kargopolov (Udemy)
License: Apache License 2.0
Tutorial - Spring Boot Microservices, CQRS, SAGA, Axon Framework - from Sergey Kargopolov (Udemy)
License: Apache License 2.0
Change docker.image.name from cqrs-${project.artifactId}
to art-kargopolov-cqrs-${project.artifactId}
Refactor project structure to have centralized version control
when testing with another tests we got an exception
See same issue fix
/orders/with_subscription
endpoint to return TEXT_EVENT_STREAMinject ProductMapper bean instead of calling ProductMapper.INSTANCE
private final String name;
private final String cardNumber;
private final int validUntilMonth;
private final int validUntilYear;
private final String cvv;
private final String firstName;
private final String lastName;
private final String userId;
private final PaymentDetails paymentDetails;
private String userId;
PaymentDetails paymentDetails = PaymentDetails.builder()
.cardNumber("123Card")
.cvv("123")
.name("SERGEY KARGOPOLOV")
.validUntilMonth(12)
.validUntilYear(2030)
.build();
User userRest = User.builder()
.firstName("Sergey")
.lastName("Kargopolov")
.userId(query.getUserId())
.paymentDetails(paymentDetails)
.build();
private final String orderId;
private final String paymentId;
@EventSourcingHandler
method that sets values for all fields in the PaymentAggregate.@Component
class called PaymentEventsHandler.@EventHandler
method that handles the PaymentProcessedEvent and persists payment details into the "read" database.@Entity
@Table(name = "payments")
@Id
private String paymentId;
@Column
public String orderId;
Error: Failures:
Error: ProductAggregateErrorHandlingTest.createProduct_errorInProductAggregate:45
Multiple Failures (1 failure)
-- failure 1 --
Expecting actual:
2022-07-28T18:53:20.959867 (java.time.LocalDateTime)
to have same year, month, day, hour, minute and second as:
2022-07-28T18:53:21.013301 (java.time.LocalDateTime)
but had not.
Create a new Spring Boot Project
Dependencies
Create OrdersCommandController
{
"productId":"f241af45-4854-43f4-95bc-ab54da338a29",
"quantity":1,
"addressId":"afbb5881-a872-4d13-993c-faeb8350eea5"
}
public final String orderId;
private final String userId;
private final String productId;
private final int quantity;
private final String addressId;
private final OrderStatus orderStatus;
orderId
- is a randomly generated value. For example, UUID.randomUUID().toString()userId
- is a static hard-coded value: 27b95829-4f3f-4ddf-8983-151ba010e35b. At this moment there is no user registration, authentication, and authorization implemented, so we will hard code the value of userId for now.orderStatus
- is an Enum with the following content:public enum OrderStatus {
CREATED, APPROVED, REJECTED
}
OrderAggregate class
private String orderId;
private String productId;
private String userId;
private int quantity;
private String addressId;
private OrderStatus orderStatus;
Create OrderEventsHandler class
@Entity
@Table(name = "orders")
@Id
@Column(unique = true)
public String orderId;
private String productId;
private String userId;
private int quantity;
private String addressId;
@Enumerated(EnumType.STRING)
private OrderStatus orderStatus;
Register with Eureka
Database
Run and make it work
{
"productId":"f241af45-4854-43f4-95bc-ab54da338a29",
"quantity":1,
"addressId":"afbb5881-a872-4d13-993c-faeb8350eea5"
}
Verify results
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.