Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

CQRS and EventSourcing with Spring & Axon

920 visualizaciones

Publicado el

There's a ton of theory available on DDD, event sourcing and CQRS but how does one get's started in terms of code? Moreover, when we have a tight deadline, one wants to solely focus on solving core business problems rather than getting caught up by plumbing non-functional concerns such as snapshotting, command handling, guaranteed events delivery to the right event listeners, events replaying, persisting aggregate, etc. In this talk, we will build an application to see how Axon Framework supports CQRS and Event sourcing by providing a robust implementation for fundamental building blocks such as event dispatching mechanism, aggregates, repositories, event sourcing, Domain Events, etc.to build scalable, extensible and maintainable applications. Furthermore, Axon provides extensive support for Spring which means much of the configuration can be avoided by leveraging Spring's annotation support.

Publicado en: Tecnología
  • Sé el primero en comentar

CQRS and EventSourcing with Spring & Axon

  1. 1. CQRS & EventSourcing With Spring & Axon By : Nakul Mishra “Success by design is infinitely better than a win by chance.” #DevoxxPL @nklmish
  2. 2. #DevoxxPL @nklmish
  3. 3. Code is like water, it reflects #DevoxxPL @nklmish
  4. 4. Our perception #DevoxxPL @nklmish
  5. 5. Business Reality #DevoxxPL @nklmish
  6. 6. DDD #DevoxxPL @nklmish
  7. 7. #DevoxxPL @nklmish DDD - Focus on domain
  8. 8. #DevoxxPL @nklmish DDD In Practice?
  9. 9. #DevoxxPL @nklmish Place behaviour in “Domain Model” DDD in a nutshell
  10. 10. #DevoxxPL @nklmish DDD in a nutshell Code should reflect “Business REALITY” (Ubiquitous language) Place behaviour in “Domain Model”
  11. 11. #DevoxxPL @nklmish Provide unit of consistency 
 across Domain Model via “Aggregate” DDD in a nutshell Code should reflect “Business REALITY” (Ubiquitous language) Place behaviour in “Domain Model”
  12. 12. #DevoxxPL @nklmish Define clear “bounded context” & 
 protect your model. DDD in a nutshell Provide unit of consistency 
 across Domain Model via “Aggregate” Code should reflect “Business REALITY” (Ubiquitous language) Place behaviour in “Domain Model”
  13. 13. Aggregate #DevoxxPL @nklmish
  14. 14. Event Sourcing #DevoxxPL @nklmish
  15. 15. Traditional app #DevoxxPL @nklmish
  16. 16. Traditional app - What Happened #DevoxxPL @nklmish 12345 1 Veggie Burger Shipped
  17. 17. Event sourcing #DevoxxPL @nklmish
  18. 18. Event Sourcing - What ACTUALLY Happened #DevoxxPL @nklmish Item Added 1 Veggie Burger
  19. 19. Event Sourcing - What ACTUALLY Happened #DevoxxPL @nklmish Item Added 1 Veggie Burger Item Added 1 Salad
  20. 20. Event Sourcing - What ACTUALLY Happened #DevoxxPL @nklmish Item Added 1 Veggie Burger Item Added 1 Salad Item Added 1 Ice cream
  21. 21. Event Sourcing - What ACTUALLY Happened #DevoxxPL @nklmish Item Added 1 Veggie Burger Item Added 1 Salad Item Added 1 Ice cream Item Removed 1 Ice cream
  22. 22. Event Sourcing - What ACTUALLY Happened #DevoxxPL @nklmish Item Added 1 Veggie Burger Item Added 1 Salad Item Added 1 Ice cream Item Removed 1 Ice cream Item Removed 1 Salad
  23. 23. Event Sourcing - What ACTUALLY Happened #DevoxxPL @nklmish Item Added 1 Veggie Burger Item Added 1 Salad Item Added 1 Ice cream Item Removed 1 Ice cream Item Removed 1 Salad OrderConfirmed
  24. 24. Event Sourcing - What ACTUALLY Happened #DevoxxPL @nklmish Item Added 1 Veggie Burger Item Added 1 Salad Item Added 1 Ice cream Item Removed 1 Ice cream Item Removed 1 Salad OrderConfirmed Order Shipped
  25. 25. Event Sourcing - What ACTUALLY Happened #DevoxxPL @nklmish Item Added 1 Veggie Burger Item Added 1 Salad Item Added 1 Ice cream Item Removed 1 Ice cream Item Removed 1 Salad OrderConfirmed Order Shipped Food for Big Data, ML, etc.
  26. 26. Where to store events? #DevoxxPL @nklmish
  27. 27. Event Store #DevoxxPL @nklmish
  28. 28. Event Store #DevoxxPL @nklmish Time
  29. 29. Event Store #DevoxxPL @nklmish Time
  30. 30. Event Store #DevoxxPL @nklmish Time
  31. 31. Event Store #DevoxxPL @nklmish Time
  32. 32. Event Store #DevoxxPL @nklmish Time
  33. 33. Event Store #DevoxxPL @nklmish validate sequence number Time
  34. 34. Event Store Implementation #DevoxxPL @nklmish • EventStore - Greg Young • AxonDB - AxonIQ • Relational DBMS • Roll out your own….
  35. 35. CQRS #DevoxxPL @nklmish
  36. 36. #DevoxxPL @nklmish I WANT SOMETHING DONE Command
  37. 37. #DevoxxPL @nklmish I WANT TO KNOW SOMETHING Query (Projections)
  38. 38. CQRS Command Query UI Command Model Projections #DevoxxPL @nklmish
  39. 39. Command Query UI Command Model Projections Events #DevoxxPL @nklmish CQRS
  40. 40. Command Query UI Command Model Projections Events #DevoxxPL @nklmish CQRS Event Store
  41. 41. Command Query UI Command Model Projections Events #DevoxxPL @nklmish CQRS Event Store
  42. 42. #DevoxxPL @nklmish
  43. 43. Really
  44. 44. #DevoxxPL @nklmish
  45. 45. #DevoxxPL @nklmish
  46. 46. #DevoxxPL @nklmish AxonFramework
  47. 47. Axon History #DevoxxPL @nklmish 2009 20182010 2011 2012 2013 2014 2015 20172016 First code
  48. 48. #DevoxxPL @nklmish 2009 20182010 2011 2012 2013 2014 2015 20172016 First code 1st Production user Axon History
  49. 49. #DevoxxPL @nklmish 2009 20182010 2011 2012 2013 2014 2015 20172016 First code 1st Production user Axon 1.0 Axon History
  50. 50. #DevoxxPL @nklmish 2009 20182010 2011 2012 2013 2014 2015 20172016 First code 1st Production user Axon 1.0 Axon 2.0 Axon History
  51. 51. #DevoxxPL @nklmish 2009 20182010 2011 2012 2013 2014 2015 20172016 First code 1st Production user Axon 1.0 Axon 3.0
 (design phase) Axon 2.0 Axon History
  52. 52. #DevoxxPL @nklmish 2009 20182010 2011 2012 2013 2014 2015 20172016 First code 1st Production user Axon 1.0 Axon 3.0
 (design phase) Axon 3.0Axon 2.0 Axon History
  53. 53. #DevoxxPL @nklmish 2009 20182010 2011 2012 2013 2014 2015 20172016 First code 1st Production user Axon 1.0 Axon 3.0
 (design phase) Axon 3.0 AxonDB/AxonHubAxon 2.0 Axon History
  54. 54. Axon, Location Transparency + Other Stuff #DevoxxPL @nklmish
  55. 55. Demo #DevoxxPL @nklmish “I hear and I forget. I see and I remember. I do and I understand.”- Confucius https://github.com/nklmish/axon-casino
  56. 56. Complex Transaction Management ? #DevoxxPL @nklmish
  57. 57. ACID? #DevoxxPL @nklmish
  58. 58. BASE Basic Availability, Soft state, Eventual consistency #DevoxxPL @nklmish
  59. 59. Saga • Use to manage BASE transactions. • React on event • Coordinates activities between • Bounded contexts • Aggregates #DevoxxPL @nklmish
  60. 60. #DevoxxPL @nklmish
  61. 61. Demo at Scale #DevoxxPL @nklmish
  62. 62. #DevoxxPL @nklmish How Can YOU Find…
  63. 63. Commands? #DevoxxPL @nklmish
  64. 64. Aggregates? #DevoxxPL @nklmish
  65. 65. Bounded Context? #DevoxxPL @nklmish
  66. 66. DomainEvent? #DevoxxPL @nklmish
  67. 67. Projections? #DevoxxPL @nklmish
  68. 68. Policy? #DevoxxPL @nklmish
  69. 69. Etc? #DevoxxPL @nklmish
  70. 70. #DevoxxPL @nklmish
  71. 71. EventStorming = bringing together people with questions & answers #DevoxxPL @nklmish
  72. 72. EventStorming = Brainstorming #DevoxxPL @nklmish
  73. 73. Event Storming, 10000 foot overview
 #DevoxxPL @nklmish
  74. 74. #DevoxxPL @nklmish
  75. 75. EventStorming #DevoxxPL @nklmish
  76. 76. #DevoxxPL @nklmish
  77. 77. Replace #DevoxxPL @nklmish
  78. 78. #DevoxxPL @nklmish
  79. 79. #DevoxxPL @nklmish
  80. 80. #DevoxxPL @nklmish
  81. 81. #DevoxxPL @nklmish invoked on EXTERNAL SYSTEM invoked on DOMAIN EVENT POLICY generates generates invokes invokestriggers translated into Final Result == Engineering Input COMMAND AGGREGATE READ MODEL
 (PROJECTIONS) COMMAND
  82. 82. Summary • Domain first, technology later. • DDD != perfection. • CQRS + Event sourcing = • Axon, theory to practise • Event Storming == collective learning • Learning & connecting dots #DevoxxPL @nklmish
  83. 83. Thank You Q&A #DevoxxPL @nklmish https://github.com/nklmish/axon-casino http://tiny.cc/lsauuy Feedback

×