building flexible and scalable applications
play

Building flexible and scalable applications Using CQRS and Axon - PowerPoint PPT Presentation

Building flexible and scalable applications Using CQRS and Axon Framework Allard Buijze abu@trifork.com @allardbz Allard Buijze CTO of Trifork Amsterdam ~ 15 years of web development experience Strong believer in DDD and CQRS


  1. Building flexible and scalable applications Using CQRS and Axon Framework Allard Buijze – abu@trifork.com – @allardbz

  2. Allard Buijze CTO of Trifork Amsterdam ~ 15 years of web development experience Strong believer in DDD and CQRS Developer and initiator of Axon Framework Java Framework for scalability and performance www.axonframework.org

  3. Layered architecture User ¡Interface ¡ Domain ¡Model ¡ Service ¡Layer ¡ Data ¡Access ¡Layer ¡

  4. Evolution of a Domain Model

  5. Evolution of a Domain Model

  6. A matter of perspective Source: ¡h;ps://en.wikipedia.org/wiki/Ambiguous_image ¡

  7. A matter of perspective

  8. Evolution of a Domain Model

  9. Big ball of “Mud” Source: ¡h;p://www.sabisabi.com/images/DungBeetle-­‑on-­‑dung.JPG ¡

  10. Microservice Architecture Source: ¡h;p://marInfowler.com/arIcles/microservices.html ¡

  11. Microservices vs Monoliths Almost ¡ all ¡ the ¡ successful ¡ microservice ¡ stories ¡ have ¡ started ¡ with ¡ a ¡ monolith ¡ that ¡ got ¡ too ¡ big ¡ and ¡ was ¡ broken ¡up ¡ Almost ¡ all ¡ the ¡ cases ¡ where ¡ I've ¡ heard ¡ of ¡ a ¡ system ¡ that ¡ was ¡ built ¡ as ¡ a ¡ microservice ¡ system ¡ from ¡ scratch, ¡it ¡has ¡ended ¡up ¡in ¡serious ¡trouble. ¡ MarIn ¡Fowler ¡ Source: ¡h;p://marInfowler.com/bliki/MonolithFirst.html ¡

  12. Desired evolution

  13. Axon Framework “CQRS Framework” for Java Open source (Apache 2 License) Simplify CQRS based applications Building blocks common in CQRS-based architectures More information: www.AxonFramework.org

  14. Axon Framework – Core Principles Message oriented Events Commands Location transparency Separate infastructure from business logic Customizable Configure to match your infrastructure, not vice versa

  15. CQRS

  16. CQRS Based Architecture Command ¡model ¡ ProjecIons ¡

  17. CQRS Based Architecture Command ¡model ¡ ProjecIons ¡ T: ¡1 ¡/ ¡s ¡ T: ¡Thr. ¡20 ¡/ ¡s ¡ T: ¡10 ¡mln ¡/ ¡s ¡ T: ¡1 ¡mln ¡/ ¡s ¡ Resp. ¡< ¡10 ¡ms ¡ Resp: ¡< ¡100 ¡ms ¡ Resp. ¡< ¡100 ¡ms ¡ Resp: ¡< ¡10 ¡ms ¡

  18. Synchronizing models Ev Events Command ¡model ¡ ProjecIons ¡

  19. How about.... Consistency ¡

  20. How about.... Code ¡duplicaIon ¡

  21. How about.... I ¡can’t ¡see ¡what ¡side-­‑effects ¡a ¡ change ¡will ¡have ¡

  22. CQRS Based Architecture

  23. Separate infrastructure from business logic A ¡ D ¡ B ¡ E ¡ C ¡

  24. Spring configuration - Simple

  25. Separate infrastructure from business logic A ¡ D ¡ B ¡ E ¡ C ¡

  26. Separate infrastructure from business logic A ¡ D ¡ B ¡ E ¡ C ¡

  27. Spring configuration – Distributed Events

  28. Separate infrastructure from business logic A ¡ D ¡ B ¡ E ¡ C ¡

  29. Separate infrastructure from business logic A ¡ D ¡ B ¡ E ¡ C ¡

  30. Spring configuration – Distributed Commands

  31. CQRS Based Architecture

  32. Axon – Command Bus API @CommandHandler ¡ public ¡void ¡ handle(CreateToDoItemCommand ¡command) ¡{ ¡ ¡ ¡ ¡ ¡// ¡handle ¡command ¡ } ¡ commandBus .dispatch(commandMessage, ¡ new ¡VoidCallback() ¡{ ¡ ¡ ¡ ¡ ¡@Override ¡ ¡ ¡ ¡ ¡ public ¡void ¡onSuccess() ¡{ ¡... ¡} ¡ ¡ ¡ ¡ ¡ ¡@Override ¡ ¡ ¡ ¡ ¡ public ¡void ¡ onFailure(Throwable ¡cause) ¡{ ¡... ¡} ¡ }); ¡

  33. Axon – Event Bus API eventBus .publish( asEventMessage ( new ¡ToDoItemCompletedEvent( “todo1” ))); ¡ @EventHandler ¡ public ¡void ¡ onEvent(ToDoItemCompletedEvent ¡event) ¡ { ¡ ¡ ¡ ¡ ¡// ¡handle ¡event ¡ } ¡

  34. CQRS Based Architecture interface ¡AggregateRoot ¡ abstract ¡class ¡AbstractAggregateRoot ¡ ¡ interface ¡EventSourcedAggregateRoot ¡ abstract ¡class ¡ AbstractAnnotatedAggregateRoot ¡

  35. The power of ubiquitous events ReacIve ¡ Polling ¡ Push ¡ Cache ¡evicIon ¡ Real-­‑Ime ¡ Event ¡Sourcing ¡ LocaIon ¡transparency ¡ Systems ¡integraIon ¡

  36. Event Sourcing

  37. Event Sourcing Orders ¡ OrderItems ¡ ID ¡ Status ¡ ID ¡ OrderID ¡ Product ¡ Count ¡ 1 ¡ Return ¡shipment ¡rcvd ¡ 1 ¡ 1 ¡ Deluxe ¡Chair ¡ 1 ¡ 2 ¡ 1 ¡ ... ¡ ... ¡ vs ¡ Seq# ¡ Event ¡ 0 ¡ OrderCreatedEvent ¡ 1 ¡ ItemAddedEvent ¡(2x ¡Deluxe ¡Chair ¡-­‑ ¡€ ¡399) ¡ 2 ¡ ItemRemovedEvent ¡(1x ¡Deluxe ¡Chair ¡-­‑ ¡€ ¡399) ¡ 3 ¡ OrderConfirmed ¡ 4 ¡ OrderCancelledByUserEvent ¡ 5 ¡ ReturnShipmentReceived ¡

  38. Event Sourcing Pros Audit trail Reconstruct query model(s) Management reports since day 1 Data analysis Cons Maintain history (upcasters) Ever-growing

  39. CQRS Based Architecture interface ¡EventStore ¡ ¡ class ¡JpaEventStore ¡ class ¡JdbcEventStore ¡ class ¡MongoEventStore ¡

  40. Apply ¡state ¡ Make ¡decisions ¡ Axon – Event Sourcing

  41. Event Sourcing - Testing Given-when-then fixtures Given some past events When I apply a new Command Expect these new Events fixture.given( new GameStartedEvent(…), new CallMadeEvent(…), new TurnChangedEvent(…) ) .when( new MakeCallCommand(…) ) .expectEvents( new CallMadeEvent(…) , new TurnChangedEvent(…) ); ¡

  42. Getting started... Download: axonframework.org/download or: maven central repository Code: github.com/AxonFramework Help: axonframework@googlegroups.com or: @axonframework

  43. Axon Framework – Some cases Finance Process automation in a top 50 bank Trading engine for ETF (index trackers) trading Pension fund calculations at a large bank On-line payment processing Gaming On-line bridge platform (bridgebig.com) On-line casino (casumo.com) Healthcare Electronic Medical Record for the Geriatric Healthcare Tracking and Tracing of equipment for dental implants Aviation Optimizing aircraft movement at several large airports

  44. More information www.axonframework.org Allard Buijze <abu@trifork.com> @allardbz / @axonframework

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend