Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Overview of the Eventuate Tram Customers and Orders application

421 Aufrufe

Veröffentlicht am

This Spring Boot/JPA application illustrates how to use the Saga and CQRS patterns in a microservice architecture.

Veröffentlicht in: Software
  • Als Erste(r) kommentieren

Overview of the Eventuate Tram Customers and Orders application

  1. 1. @crichardson About the Eventuate Tram Customers and Orders example Chris Richardson Founder of Eventuate.io Founder of the original CloudFoundry.com Author of POJOs in Action @crichardson chris@chrisrichardson.net http://microservices.io http://eventuate.io Copyright © 2020. Chris Richardson Consulting, Inc. All rights reserved
  2. 2. @crichardson About the example Demonstrates two key patterns: Sagas - implement transactions that span services, https:// microservices.io/patterns/data/saga.html CQRS - implement queries that retrieve data from multiple services, https://microservices.io/patterns/data/cqrs.html Built using Spring Boot, JPA and the Eventuate Tram framework https://github.com/eventuate-tram/eventuate-tram-examples-customers-and-orders/ Note: this presentation describes the development branch , which reorganized/renamed the service modules. These changes will soon be merged into master
  3. 3. @crichardson System operations CustomersAndOrdersApplication ≪commands≫ createCustomer(name, creditLimit) createOrder(customerId, orderTotal) cancelOrder(orderID) ≪queries≫ findOrder(orderId) findOrderHistory(customerId)
  4. 4. @crichardson Services
  5. 5. @crichardson Customer Service - canvas
  6. 6. @crichardson Customer Service - domain model
  7. 7. @crichardson Order Service - canvas
  8. 8. @crichardson Order Service - domain model
  9. 9. @crichardson Order History Service - canvas
  10. 10. @crichardson Technical architecture Service: REST endpoint Pub/sub events Relational database - MySQL database Message broker Eventuate CDC - implements the Transaction Outbox pattern
  11. 11. @crichardson
  12. 12. @crichardson Why all these events!?
  13. 13. @crichardson Using the Saga pattern Customer has a credit limit createOrder() Creates Order Reserves credit cancelOrder() Updates Order Releases credit Event-driven a.k.a Choreography-based sagas https://microservices.io/patterns/data/saga.html
  14. 14. Using the CQRS pattern findOrderHistory() Returns customers and their orders Order History Service uses events to maintain a replica in MongoDB https://microservices.io/patterns/data/cqrs.html
  15. 15. @crichardson Customer Service Customer Controller Message Producer createCustomer() Customer* Events Order Event Consumer Order* events Customer Database ≪entity≫ Customer Customer Repository ≪service≫ Customer Service Domain Event Publisher POST /customers
  16. 16. Customer Service - code customer-service-api- messaging - events published by the service customer-service-api-web - DTOs for REST resources customer-service - service implementation
  17. 17. @crichardson Order Service Order Controller Message Producer createOrder() cancelOrder() Order* Events Customer Event Consumer Customer* events Order Database ≪entity≫ Order Order Repository ≪service≫ Order Service Domain Event Publisher POST /customers
  18. 18. Order Service - code order-service-api- messaging - events published by the service order-service-api-web - DTOs for REST requests and responses order-service - service implementation
  19. 19. @crichardson Order History Service CustomerOrder HistoryController findOrderHistory() Order History Event Consumer Order* events Order History Databas CustomerView Repository ≪service≫Ord erHistory ViewService POST /customers Customer* events
  20. 20. Order History Service - code order-history-service-api- web - DTOs for REST requests and responses order-service - service implementation
  21. 21. @crichardson Using the Saga pattern https://microservices.io/patterns/data/saga.html
  22. 22. @crichardson createOrder() sequence diagram
  23. 23. @crichardson cancelOrder() sequence diagram
  24. 24. @crichardson Using the CQRS pattern https://microservices.io/patterns/data/cqrs.html
  25. 25. @crichardson Implementing findOrderHistory()
  26. 26. @crichardson @crichardson chris@chrisrichardson.net http://eventuate.io Questions?

×